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'Author note: I think some of you might remember the problem "Two Melodies" from Eductational Codeforces Round 22. Now it 's time to make it a bit more difficult! Alice is a composer, and recently she had recorded two tracks that became very popular. Now she has got a lot of fans who are waiting for new tracks. This time Alice wants to form four melodies for her tracks. Alice has a sheet with n notes written on it. She wants to take four such non-empty non-intersecting subsequences that all 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 differ by 1 or are congruent modulo 7. You should write a program which will calculate maximum sum of lengths of such four non-empty non-intersecting subsequences that all of them form a melody. The first line contains one integer number n (4 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n xe2 x80 x89 xe2 x89 xa4 xe2 x80 x893000). 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 four non-empty non-intersecting subsequences that all of them form a melody. In the first example it is possible to compose 4 melodies by choosing any 4 notes (and each melody will consist of only one note). In the second example it is possible to compose one melody with 2 notes -- {1, xe2 x80 x892}. Remaining notes are used in other three melodies (one note per each melody). '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
38334950 |
vjudge3 |
G |
May 16, 2018, 11:57 p.m. |
OK |
GNU C++ |
TESTS |
63 |
46 |
5324800 |
|
2700 |
28209318 |
jasonvictoryan |
G |
July 2, 2017, 11:36 a.m. |
OK |
GNU C++ |
TESTS |
63 |
124 |
36659200 |
|
2700 |
28201442 |
stony_oi |
G |
July 2, 2017, 2:02 a.m. |
OK |
GNU C++ |
TESTS |
63 |
217 |
34713600 |
|
2700 |
28183779 |
cyand1317 |
G |
July 1, 2017, 4:17 a.m. |
OK |
GNU C++ |
TESTS |
63 |
218 |
34406400 |
|
2700 |
33798972 |
Worldwide_D |
G |
Dec. 30, 2017, 2:20 a.m. |
OK |
GNU C++ |
TESTS |
63 |
265 |
4198400 |
|
2700 |
29277549 |
ThoseBygones |
G |
Aug. 8, 2017, 4:44 a.m. |
OK |
GNU C++ |
TESTS |
63 |
358 |
964096000 |
|
2700 |
29633245 |
BeLikeIroh |
G |
Aug. 21, 2017, 2:17 a.m. |
OK |
GNU C++ |
TESTS |
63 |
390 |
1945600 |
|
2700 |
28350238 |
Zars19 |
G |
July 7, 2017, 1:26 p.m. |
OK |
GNU C++ |
TESTS |
63 |
421 |
162918400 |
|
2700 |
28350146 |
Zars19 |
G |
July 7, 2017, 1:19 p.m. |
OK |
GNU C++ |
TESTS |
63 |
421 |
162918400 |
|
2700 |
30616158 |
SeventeenYears |
G |
Sept. 22, 2017, 1:41 p.m. |
OK |
GNU C++ |
TESTS |
63 |
421 |
850022400 |
|
2700 |
39078454 |
xsc |
G |
June 9, 2018, 8:41 p.m. |
OK |
GNU C++11 |
TESTS |
63 |
31 |
1740800 |
|
2700 |
28175091 |
akmintro |
G |
June 30, 2017, 2:37 p.m. |
OK |
GNU C++11 |
TESTS |
63 |
31 |
4710400 |
|
2700 |
40980674 |
ReaLNero1 |
G |
July 30, 2018, 5:38 p.m. |
OK |
GNU C++11 |
TESTS |
63 |
46 |
2560000 |
|
2700 |
59538370 |
danya090699 |
G |
Aug. 26, 2019, 5:50 p.m. |
OK |
GNU C++11 |
TESTS |
63 |
46 |
3891200 |
|
2700 |
28153104 |
Akigeor |
G |
June 29, 2017, 5 p.m. |
OK |
GNU C++11 |
TESTS |
63 |
46 |
4505600 |
|
2700 |
28148920 |
Akigeor |
G |
June 29, 2017, 4:10 p.m. |
OK |
GNU C++11 |
TESTS |
63 |
46 |
5529600 |
|
2700 |
28281496 |
Vlad_kv |
G |
July 4, 2017, 1:24 p.m. |
OK |
GNU C++11 |
TESTS |
63 |
46 |
5632000 |
|
2700 |
51400411 |
NewYearNewHandle |
G |
March 17, 2019, 7:01 a.m. |
OK |
GNU C++11 |
TESTS |
63 |
46 |
6144000 |
|
2700 |
51400361 |
NewYearNewHandle |
G |
March 17, 2019, 6:59 a.m. |
OK |
GNU C++11 |
TESTS |
63 |
46 |
6144000 |
|
2700 |
28281465 |
Vlad_kv |
G |
July 4, 2017, 1:23 p.m. |
OK |
GNU C++11 |
TESTS |
63 |
62 |
5632000 |
|
2700 |
28193043 |
ver1tas |
G |
July 1, 2017, 2:05 p.m. |
OK |
GNU C++14 |
TESTS |
63 |
31 |
3788800 |
|
2700 |
28192791 |
ver1tas |
G |
July 1, 2017, 1:48 p.m. |
OK |
GNU C++14 |
TESTS |
63 |
31 |
4198400 |
|
2700 |
28191742 |
ver1tas |
G |
July 1, 2017, 12:42 p.m. |
OK |
GNU C++14 |
TESTS |
63 |
31 |
5017600 |
|
2700 |
29469885 |
-Morass- |
G |
Aug. 14, 2017, 11:32 p.m. |
OK |
GNU C++14 |
TESTS |
63 |
31 |
5734400 |
|
2700 |
29469852 |
vjudge1 |
G |
Aug. 14, 2017, 11:25 p.m. |
OK |
GNU C++14 |
TESTS |
63 |
31 |
5734400 |
|
2700 |
29469822 |
vjudge4 |
G |
Aug. 14, 2017, 11:20 p.m. |
OK |
GNU C++14 |
TESTS |
63 |
31 |
5734400 |
|
2700 |
29469791 |
vjudge5 |
G |
Aug. 14, 2017, 11:16 p.m. |
OK |
GNU C++14 |
TESTS |
63 |
31 |
5734400 |
|
2700 |
29469779 |
vjudge1 |
G |
Aug. 14, 2017, 11:13 p.m. |
OK |
GNU C++14 |
TESTS |
63 |
31 |
5734400 |
|
2700 |
29469693 |
vjudge5 |
G |
Aug. 14, 2017, 11:01 p.m. |
OK |
GNU C++14 |
TESTS |
63 |
31 |
5734400 |
|
2700 |
29469670 |
vjudge3 |
G |
Aug. 14, 2017, 10:57 p.m. |
OK |
GNU C++14 |
TESTS |
63 |
31 |
5734400 |
|
2700 |
61448313 |
Kuroni |
G |
Sept. 28, 2019, 11:11 p.m. |
OK |
GNU C++17 |
TESTS |
63 |
31 |
3174400 |
|
2700 |
61448347 |
Kuroni |
G |
Sept. 28, 2019, 11:14 p.m. |
OK |
GNU C++17 |
TESTS |
63 |
46 |
3174400 |
|
2700 |
61448326 |
tfg |
G |
Sept. 28, 2019, 11:12 p.m. |
OK |
GNU C++17 |
TESTS |
63 |
46 |
3174400 |
|
2700 |
66258628 |
tsutaj1458 |
G |
Dec. 4, 2019, 7:21 a.m. |
OK |
GNU C++17 |
TESTS |
63 |
124 |
5017600 |
|
2700 |
58145552 |
ggml |
G |
Aug. 1, 2019, 8:54 p.m. |
OK |
GNU C++17 |
TESTS |
63 |
217 |
3686400 |
|
2700 |
46393381 |
Slaaava |
G |
Nov. 30, 2018, 7:32 a.m. |
OK |
GNU C++17 |
TESTS |
63 |
265 |
3481600 |
|
2700 |
38552013 |
oneplus54 |
G |
May 23, 2018, 5:38 a.m. |
OK |
GNU C++17 |
TESTS |
63 |
312 |
1843200 |
|
2700 |
42658183 |
vjudge3 |
G |
Sept. 8, 2018, 1:19 a.m. |
OK |
GNU C++17 |
TESTS |
63 |
358 |
2150400 |
|
2700 |
64736551 |
hugopm |
G |
Nov. 12, 2019, 10:32 a.m. |
OK |
GNU C++17 |
TESTS |
63 |
358 |
4300800 |
|
2700 |
62427375 |
Umi |
G |
Oct. 12, 2019, 2:41 p.m. |
OK |
GNU C++17 |
TESTS |
63 |
389 |
3276800 |
|
2700 |
28971304 |
dalt |
G |
July 29, 2017, 1:27 p.m. |
OK |
Java 8 |
TESTS |
63 |
264 |
22528000 |
|
2700 |
28784016 |
jtnydv25 |
G |
July 22, 2017, 5:21 p.m. |
OK |
Java 8 |
TESTS |
63 |
1200 |
23040000 |
|
2700 |
28177564 |
Musin |
G |
June 30, 2017, 5:15 p.m. |
OK |
Java 8 |
TESTS |
63 |
3977 |
494899200 |
|
2700 |
28294114 |
uwi |
G |
July 5, 2017, 4:48 a.m. |
OK |
Java 8 |
TESTS |
63 |
4477 |
22220800 |
|
2700 |
28202709 |
mosfjh |
G |
July 2, 2017, 3:41 a.m. |
OK |
MS C++ |
TESTS |
63 |
374 |
43929600 |
|
2700 |
56184342 |
vjudge1 |
G |
June 28, 2019, 3:19 a.m. |
OK |
MS C++ |
TESTS |
63 |
467 |
1433600 |
|
2700 |
37262508 |
Hzoi_joker |
G |
April 13, 2018, 12:53 a.m. |
OK |
MS C++ |
TESTS |
63 |
1450 |
40038400 |
|
2700 |
remove filters
Back to search problems