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"You're given an array consisting of n integers. You have to perform n turns. Initially your score is 0 . On the i -th turn, you are allowed to leave the array as it is or swap any one pair of 2 adjacent elements in the array and change exactly one of them to 0 (and leave the value of other element unchanged) after swapping. In either case(whether you swap or not), after this you add a_i to your score. What's the maximum possible score you can get? The first line contains a single integer n ( 2 <= n <= 500 ). The second line contains n integers a_1, a_2, ldots, a_n ( 1 <= a_i <= 10^6 ). Print a single integer -- the maximum possible score. In the first example, to get the maximum score we do as follows. Do nothing on the first turn, add 3 to the score. Swap the first and the second elements and turn 1 to 0 on the second turn, and add 3 to the score. The final score is 6 . "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
175487242 |
Queendc |
E |
Oct. 11, 2022, 1:11 a.m. |
OK |
GNU C++14 |
TESTS |
21 |
62 |
2048000 |
|
|
175450095 |
Kalam |
E |
Oct. 10, 2022, 5:43 p.m. |
OK |
GNU C++14 |
TESTS |
21 |
311 |
5324800 |
|
|
175437431 |
2514631360a |
E |
Oct. 10, 2022, 4:22 p.m. |
OK |
GNU C++14 |
TESTS |
21 |
530 |
8192000 |
|
|
175437003 |
lexiyvv |
E |
Oct. 10, 2022, 4:21 p.m. |
OK |
GNU C++14 |
TESTS |
21 |
888 |
516198400 |
|
|
175486350 |
fengzhengwei |
E |
Oct. 11, 2022, 12:47 a.m. |
OK |
GNU C++14 |
TESTS |
21 |
1497 |
15257600 |
|
|
175438942 |
yjt1799067408 |
E |
Oct. 10, 2022, 4:25 p.m. |
OK |
GNU C++14 |
TESTS |
21 |
1778 |
15257600 |
|
|
175492926 |
yyyz04 |
E |
Oct. 11, 2022, 3:05 a.m. |
OK |
GNU C++17 |
TESTS |
21 |
171 |
2048000 |
|
|
175491033 |
teng |
E |
Oct. 11, 2022, 2:30 a.m. |
OK |
GNU C++17 |
TESTS |
21 |
218 |
2048000 |
|
|
175491003 |
teng |
E |
Oct. 11, 2022, 2:30 a.m. |
OK |
GNU C++17 |
TESTS |
21 |
218 |
2048000 |
|
|
175459784 |
aa2985759 |
E |
Oct. 10, 2022, 7:19 p.m. |
OK |
GNU C++17 |
TESTS |
21 |
343 |
2048000 |
|
|
175500456 |
yyyz04 |
E |
Oct. 11, 2022, 5:13 a.m. |
OK |
GNU C++17 |
TESTS |
21 |
343 |
7065600 |
|
|
175438926 |
Yzm007 |
E |
Oct. 10, 2022, 4:25 p.m. |
OK |
GNU C++17 |
TESTS |
21 |
390 |
2048000 |
|
|
175442810 |
20Ti_ntson |
E |
Oct. 10, 2022, 4:34 p.m. |
OK |
GNU C++17 |
TESTS |
21 |
546 |
519270400 |
|
|
175460779 |
dmenezes |
E |
Oct. 10, 2022, 7:30 p.m. |
OK |
GNU C++17 |
TESTS |
21 |
561 |
517222400 |
|
|
175447389 |
dmenezes |
E |
Oct. 10, 2022, 5:23 p.m. |
OK |
GNU C++17 |
TESTS |
21 |
623 |
510054400 |
|
|
175435975 |
superMOOZ |
E |
Oct. 10, 2022, 4:19 p.m. |
OK |
GNU C++17 |
TESTS |
21 |
655 |
5120000 |
|
|
175485748 |
zihouzhong |
E |
Oct. 11, 2022, 12:30 a.m. |
OK |
GNU C++17 (64) |
TESTS |
21 |
218 |
2457600 |
|
|
175442862 |
ei133333 |
E |
Oct. 10, 2022, 4:34 p.m. |
OK |
GNU C++17 (64) |
TESTS |
21 |
296 |
2662400 |
|
|
175485647 |
relyt871 |
E |
Oct. 11, 2022, 12:26 a.m. |
OK |
GNU C++17 (64) |
TESTS |
21 |
374 |
2048000 |
|
|
175450854 |
Kude |
E |
Oct. 10, 2022, 5:49 p.m. |
OK |
GNU C++17 (64) |
TESTS |
21 |
374 |
2048000 |
|
|
175484407 |
ezoilearner |
E |
Oct. 10, 2022, 11:46 p.m. |
OK |
GNU C++17 (64) |
TESTS |
21 |
374 |
517222400 |
|
|
175494093 |
yzc2005 |
E |
Oct. 11, 2022, 3:26 a.m. |
OK |
GNU C++17 (64) |
TESTS |
21 |
468 |
3072000 |
|
|
175438010 |
potato167 |
E |
Oct. 10, 2022, 4:23 p.m. |
OK |
GNU C++17 (64) |
TESTS |
21 |
514 |
2764800 |
|
|
175489225 |
SanweiTreap |
E |
Oct. 11, 2022, 1:55 a.m. |
OK |
GNU C++17 (64) |
TESTS |
21 |
592 |
5017600 |
|
|
175467949 |
enslaved |
E |
Oct. 10, 2022, 9:23 p.m. |
OK |
GNU C++17 (64) |
TESTS |
21 |
670 |
527564800 |
|
|
175488489 |
xcyle |
E |
Oct. 11, 2022, 1:38 a.m. |
OK |
GNU C++17 (64) |
TESTS |
21 |
716 |
517222400 |
|
|
175488297 |
realRainFestivalqwq |
E |
Oct. 11, 2022, 1:34 a.m. |
OK |
GNU C++20 (64) |
TESTS |
21 |
78 |
3993600 |
|
|
175502861 |
huyaowen |
E |
Oct. 11, 2022, 5:44 a.m. |
OK |
GNU C++20 (64) |
TESTS |
21 |
171 |
2048000 |
|
|
175466031 |
huangxiaohua |
E |
Oct. 10, 2022, 8:47 p.m. |
OK |
GNU C++20 (64) |
TESTS |
21 |
171 |
2048000 |
|
|
175494948 |
Emotiona |
E |
Oct. 11, 2022, 3:42 a.m. |
OK |
GNU C++20 (64) |
TESTS |
21 |
171 |
8499200 |
|
|
175489862 |
Emotiona |
E |
Oct. 11, 2022, 2:09 a.m. |
OK |
GNU C++20 (64) |
TESTS |
21 |
171 |
8499200 |
|
|
175494722 |
Duck_sajin |
E |
Oct. 11, 2022, 3:38 a.m. |
OK |
GNU C++20 (64) |
TESTS |
21 |
187 |
1126400 |
|
|
175488001 |
superguymj |
E |
Oct. 11, 2022, 1:28 a.m. |
OK |
GNU C++20 (64) |
TESTS |
21 |
187 |
2048000 |
|
|
175465923 |
huangxiaohua |
E |
Oct. 10, 2022, 8:45 p.m. |
OK |
GNU C++20 (64) |
TESTS |
21 |
187 |
2150400 |
|
|
175499954 |
KroosTheKeenGlint |
E |
Oct. 11, 2022, 5:06 a.m. |
OK |
GNU C++20 (64) |
TESTS |
21 |
187 |
4096000 |
|
|
175448431 |
jiangly |
E |
Oct. 10, 2022, 5:30 p.m. |
OK |
GNU C++20 (64) |
TESTS |
21 |
265 |
1126400 |
|
|
175454531 |
Dukkha |
E |
Oct. 10, 2022, 6:21 p.m. |
OK |
Java 17 |
TESTS |
21 |
1185 |
2355200 |
|
|
175456718 |
Dukkha |
E |
Oct. 10, 2022, 6:42 p.m. |
OK |
Java 17 |
TESTS |
21 |
1201 |
2457600 |
|
|
175457027 |
Dukkha |
E |
Oct. 10, 2022, 6:46 p.m. |
OK |
Java 17 |
TESTS |
21 |
1216 |
2560000 |
|
|
remove filters
Back to search problems