Solutions are presented as using the least memory and the fastest execution time. It also takes the top
10 most recent solutions from each language. If you want to limit to a specific index, click the
"Solved" button and go to that problem.
Problems
B'Alice is a beginner composer and now she is ready to create another masterpiece. And not even the single one but two at the same time! Alice has a sheet with n notes written on it. She wants to take two such non-empty non-intersecting subsequences that both of them form a melody and sum of their lengths is maximal. Subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. Subsequence forms a melody when each two adjacent notes either differs by 1 or are congruent modulo 7. You should write a program which will calculate maximum sum of lengths of such two non-empty non-intersecting subsequences that both of them form a melody. The first line contains one integer number n (2 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n xe2 x80 x89 xe2 x89 xa4 xe2 x80 x895000). The second line contains n integer numbers a1, xe2 x80 x89a2, xe2 x80 x89..., xe2 x80 x89an (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89ai xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89105) -- notes written on a sheet. Print maximum sum of lengths of such two non-empty non-intersecting subsequences that both of them form a melody. In the first example subsequences [1, xe2 x80 x892] and [4, xe2 x80 x895] give length 4 in total. In the second example subsequences [62, xe2 x80 x8948, xe2 x80 x8949] and [60, xe2 x80 x8961] give length 5 in total. If you choose subsequence [62, xe2 x80 x8961] in the first place then the second melody will have maximum length 2, that gives the result of 4, which is not maximal. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
27617429 |
rainboy |
D |
June 6, 2017, 3:43 p.m. |
OK |
GNU C |
TESTS |
35 |
327 |
100352000 |
|
2700 |
27733883 |
faultrit |
D |
June 12, 2017, 8:22 a.m. |
OK |
GNU C |
TESTS |
35 |
373 |
100659200 |
|
2700 |
41902839 |
luogu_bot2 |
D |
Aug. 20, 2018, 1:05 p.m. |
OK |
GNU C++ |
TESTS |
35 |
265 |
102604800 |
|
2700 |
29612181 |
ThoseBygones |
D |
Aug. 20, 2017, 3:35 a.m. |
OK |
GNU C++ |
TESTS |
35 |
296 |
100864000 |
|
2700 |
38604088 |
zjo_2001 |
D |
May 25, 2018, 8:39 a.m. |
OK |
GNU C++ |
TESTS |
35 |
296 |
100966400 |
|
2700 |
28253145 |
vjudge5 |
D |
July 3, 2017, 11:01 a.m. |
OK |
GNU C++ |
TESTS |
35 |
296 |
102912000 |
|
2700 |
27965328 |
strawberrry |
D |
June 22, 2017, 12:51 p.m. |
OK |
GNU C++ |
TESTS |
35 |
296 |
102912000 |
|
2700 |
27965257 |
strawberrry |
D |
June 22, 2017, 12:46 p.m. |
OK |
GNU C++ |
TESTS |
35 |
296 |
102912000 |
|
2700 |
27965249 |
strawberrry |
D |
June 22, 2017, 12:45 p.m. |
OK |
GNU C++ |
TESTS |
35 |
296 |
102912000 |
|
2700 |
41001628 |
1970966462 |
D |
July 31, 2018, 7:25 a.m. |
OK |
GNU C++ |
TESTS |
35 |
311 |
100864000 |
|
2700 |
40974394 |
1970966462 |
D |
July 30, 2018, 2:41 p.m. |
OK |
GNU C++ |
TESTS |
35 |
311 |
100864000 |
|
2700 |
40974274 |
oilover |
D |
July 30, 2018, 2:38 p.m. |
OK |
GNU C++ |
TESTS |
35 |
311 |
100864000 |
|
2700 |
36347233 |
ellensoprano |
D |
March 17, 2018, 8:18 a.m. |
OK |
GNU C++11 |
TESTS |
35 |
156 |
8908800 |
|
2700 |
28319359 |
tahsynx |
D |
July 6, 2017, 7:28 a.m. |
OK |
GNU C++11 |
TESTS |
35 |
156 |
8908800 |
|
2700 |
36347110 |
ellensoprano |
D |
March 17, 2018, 8:13 a.m. |
OK |
GNU C++11 |
TESTS |
35 |
171 |
8908800 |
|
2700 |
48720070 |
YenSean |
D |
Jan. 22, 2019, 1:08 p.m. |
OK |
GNU C++11 |
TESTS |
35 |
171 |
50380800 |
|
2700 |
47162028 |
__Salty__ |
D |
Dec. 17, 2018, 10:28 a.m. |
OK |
GNU C++11 |
TESTS |
35 |
202 |
100761600 |
|
2700 |
48114556 |
vjudge1 |
D |
Jan. 9, 2019, 11:52 a.m. |
OK |
GNU C++11 |
TESTS |
35 |
202 |
100864000 |
|
2700 |
48113481 |
xgzc |
D |
Jan. 9, 2019, 11:07 a.m. |
OK |
GNU C++11 |
TESTS |
35 |
202 |
100864000 |
|
2700 |
49616205 |
gayathriamulya98 |
D |
Feb. 8, 2019, 6:20 a.m. |
OK |
GNU C++11 |
TESTS |
35 |
202 |
101068800 |
|
2700 |
49616174 |
Sherek |
D |
Feb. 8, 2019, 6:19 a.m. |
OK |
GNU C++11 |
TESTS |
35 |
202 |
101068800 |
|
2700 |
47875417 |
vjudge2 |
D |
Jan. 3, 2019, 3:06 p.m. |
OK |
GNU C++11 |
TESTS |
35 |
202 |
180736000 |
|
2700 |
64323431 |
RedNextCentury |
D |
Nov. 5, 2019, 4:26 p.m. |
OK |
GNU C++14 |
TESTS |
35 |
108 |
21708800 |
|
2700 |
64323479 |
RedNextCentury |
D |
Nov. 5, 2019, 4:27 p.m. |
OK |
GNU C++14 |
TESTS |
35 |
124 |
17612800 |
|
2700 |
40980803 |
ReaLNero1 |
D |
July 30, 2018, 5:42 p.m. |
OK |
GNU C++14 |
TESTS |
35 |
156 |
13312000 |
|
2700 |
28304090 |
GreenGrape |
D |
July 5, 2017, 12:44 p.m. |
OK |
GNU C++14 |
TESTS |
35 |
156 |
15155200 |
|
2700 |
27687081 |
consecutivelimit |
D |
June 9, 2017, 10:32 a.m. |
OK |
GNU C++14 |
TESTS |
35 |
202 |
101171200 |
|
2700 |
49927265 |
vjudge4 |
D |
Feb. 15, 2019, 12:32 a.m. |
OK |
GNU C++14 |
TESTS |
35 |
233 |
101068800 |
|
2700 |
49870975 |
nvmdava |
D |
Feb. 13, 2019, 1:52 p.m. |
OK |
GNU C++14 |
TESTS |
35 |
233 |
101068800 |
|
2700 |
66550678 |
Samaritan_infi |
D |
Dec. 9, 2019, 2:48 p.m. |
OK |
GNU C++14 |
TESTS |
35 |
234 |
100864000 |
|
2700 |
31229762 |
DOlaBMOon |
D |
Oct. 12, 2017, 12:49 a.m. |
OK |
GNU C++14 |
TESTS |
35 |
249 |
100659200 |
|
2700 |
63399197 |
imAnik |
D |
Oct. 25, 2019, 5:42 p.m. |
OK |
GNU C++14 |
TESTS |
35 |
249 |
100864000 |
|
2700 |
61433416 |
FallingStar |
D |
Sept. 28, 2019, 3:35 p.m. |
OK |
GNU C++17 |
TESTS |
35 |
186 |
100761600 |
|
2700 |
47447402 |
PhoenixGS |
D |
Dec. 24, 2018, 7:17 a.m. |
OK |
GNU C++17 |
TESTS |
35 |
218 |
101273600 |
|
2700 |
46890089 |
yangjinhao |
D |
Dec. 11, 2018, 5:13 a.m. |
OK |
GNU C++17 |
TESTS |
35 |
233 |
100761600 |
|
2700 |
60012481 |
qinding |
D |
Sept. 4, 2019, 11:16 a.m. |
OK |
GNU C++17 |
TESTS |
35 |
233 |
101068800 |
|
2700 |
52373133 |
Vwsrenzk_ZC |
D |
April 6, 2019, 7:07 a.m. |
OK |
GNU C++17 |
TESTS |
35 |
249 |
102604800 |
|
2700 |
43923832 |
xgcxgc |
D |
Oct. 7, 2018, 3:12 a.m. |
OK |
GNU C++17 |
TESTS |
35 |
249 |
104345600 |
|
2700 |
67259516 |
Moririn2528 |
D |
Dec. 20, 2019, 2:13 a.m. |
OK |
GNU C++17 |
TESTS |
35 |
249 |
124211200 |
|
2700 |
68331450 |
NonGoxicTum |
D |
Jan. 6, 2020, 7 p.m. |
OK |
GNU C++17 |
TESTS |
35 |
264 |
100761600 |
|
2700 |
62628074 |
hkyiitd |
D |
Oct. 15, 2019, 2:38 p.m. |
OK |
GNU C++17 |
TESTS |
35 |
265 |
100864000 |
|
2700 |
67565164 |
Martin53 |
D |
Dec. 24, 2019, 6:58 p.m. |
OK |
GNU C++17 |
TESTS |
35 |
295 |
251187200 |
|
2700 |
28314383 |
JialinOuyang |
D |
July 6, 2017, 1:51 a.m. |
OK |
Java 8 |
TESTS |
35 |
780 |
165376000 |
|
2700 |
27616781 |
Dukkha |
D |
June 6, 2017, 3:06 p.m. |
OK |
Java 8 |
TESTS |
35 |
872 |
139571200 |
|
2700 |
27764962 |
2019cjin |
D |
June 13, 2017, 11:57 p.m. |
OK |
Java 8 |
TESTS |
35 |
1060 |
145920000 |
|
2700 |
27687393 |
olya-chuchuk |
D |
June 9, 2017, 10:56 a.m. |
OK |
Java 8 |
TESTS |
35 |
1153 |
145715200 |
|
2700 |
27967623 |
mug |
D |
June 22, 2017, 2:44 p.m. |
OK |
Java 8 |
TESTS |
35 |
1153 |
165171200 |
|
2700 |
28000424 |
xodiac |
D |
June 24, 2017, 8:14 a.m. |
OK |
Java 8 |
TESTS |
35 |
1200 |
174796800 |
|
2700 |
28126407 |
jfella |
D |
June 28, 2017, 8 p.m. |
OK |
Java 8 |
TESTS |
35 |
1294 |
165376000 |
|
2700 |
28270237 |
JialinOuyang |
D |
July 4, 2017, 4:41 a.m. |
OK |
Java 8 |
TESTS |
35 |
1418 |
165478400 |
|
2700 |
27693587 |
Kammola |
D |
June 9, 2017, 5:17 p.m. |
OK |
Java 8 |
TESTS |
35 |
1622 |
139059200 |
|
2700 |
28066723 |
JialinOuyang |
D |
June 27, 2017, 1:36 a.m. |
OK |
Java 8 |
TESTS |
35 |
1699 |
165888000 |
|
2700 |
27911782 |
leign |
D |
June 19, 2017, 7:28 p.m. |
OK |
Mono C# |
TESTS |
35 |
530 |
103833600 |
|
2700 |
28207375 |
kawazaki |
D |
July 2, 2017, 9:27 a.m. |
OK |
MS C# |
TESTS |
35 |
685 |
116121600 |
|
2700 |
47157793 |
vjudge5 |
D |
Dec. 17, 2018, 8 a.m. |
OK |
MS C++ |
TESTS |
35 |
248 |
100864000 |
|
2700 |
27745036 |
Euler2718 |
D |
June 12, 2017, 9:06 p.m. |
OK |
MS C++ |
TESTS |
35 |
436 |
100864000 |
|
2700 |
27685107 |
mshcherba |
D |
June 9, 2017, 8:19 a.m. |
OK |
MS C++ |
TESTS |
35 |
467 |
100864000 |
|
2700 |
27675382 |
Filyan |
D |
June 8, 2017, 4:25 p.m. |
OK |
MS C++ |
TESTS |
35 |
795 |
102604800 |
|
2700 |
27674310 |
Filyan |
D |
June 8, 2017, 3:16 p.m. |
OK |
MS C++ |
TESTS |
35 |
857 |
102195200 |
|
2700 |
27673460 |
Filyan |
D |
June 8, 2017, 2:28 p.m. |
OK |
MS C++ |
TESTS |
35 |
982 |
102195200 |
|
2700 |
27673750 |
nanae1914 |
D |
June 8, 2017, 2:45 p.m. |
OK |
PyPy 3 |
TESTS |
35 |
1404 |
104243200 |
|
2700 |
remove filters
Back to search problems