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"During her tantrums the princess usually smashes some collectable porcelain. Every furious shriek is accompanied with one item smashed. The collection of porcelain is arranged neatly on n shelves. Within each shelf the items are placed in one row, so that one can access only the outermost items -- the leftmost or the rightmost item, not the ones in the middle of the shelf. Once an item is taken, the next item on that side of the shelf can be accessed (see example). Once an item is taken, it can't be returned to the shelves. You are given the values of all items. Your task is to find the maximal damage the princess' tantrum of m shrieks can inflict on the collection of porcelain. The first line of input data contains two integers n (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89100) and m (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89m xe2 x80 x89 xe2 x89 xa4 xe2 x80 x8910000). The next n lines contain the values of the items on the shelves: the first number gives the number of items on this shelf (an integer between 1 and 100, inclusive), followed by the values of the items (integers between 1 and 100, inclusive), in the order in which they appear on the shelf (the first number corresponds to the leftmost item, the last one -- to the rightmost one). The total number of items is guaranteed to be at least m. Output the maximal total value of a tantrum of m shrieks. In the first case there are two shelves, each with three items. To maximize the total value of the items chosen, one can take two items from the left side of the first shelf and one item from the right side of the second shelf. In the second case there is only one shelf, so all three items are taken from it -- two from the left side and one from the right side."... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
15143978 |
HappyNewYearMike |
E |
Dec. 31, 2015, 11:58 p.m. |
OK |
Delphi |
TESTS |
61 |
140 |
20889600 |
|
2000 |
50154991 |
AHTOH._. |
E |
Feb. 19, 2019, 9:30 a.m. |
OK |
FPC |
TESTS |
61 |
234 |
4300800 |
|
2000 |
19968285 |
Gray_58 |
E |
Aug. 19, 2016, 5:26 p.m. |
OK |
FPC |
TESTS |
61 |
280 |
148582400 |
|
2000 |
15748001 |
Astreb |
E |
Feb. 2, 2016, 10:34 a.m. |
OK |
FPC |
TESTS |
61 |
343 |
204800 |
|
2000 |
36427622 |
NextB |
E |
March 20, 2018, 8:17 a.m. |
OK |
FPC |
TESTS |
61 |
717 |
246169600 |
|
2000 |
19556441 |
vjudge2 |
E |
Aug. 1, 2016, 9:25 a.m. |
OK |
GNU C |
TESTS |
61 |
124 |
409600 |
|
2000 |
41916630 |
kjain1810 |
E |
Aug. 20, 2018, 10:33 p.m. |
OK |
GNU C |
TESTS |
61 |
358 |
8396800 |
|
2000 |
38204034 |
vjudge5 |
E |
May 14, 2018, 2:31 a.m. |
OK |
GNU C++ |
TESTS |
61 |
46 |
3686400 |
|
2000 |
38268413 |
vjudge3 |
E |
May 15, 2018, 1:09 p.m. |
OK |
GNU C++ |
TESTS |
61 |
46 |
8294400 |
|
2000 |
38194210 |
vjudge4 |
E |
May 13, 2018, 2:49 p.m. |
OK |
GNU C++ |
TESTS |
61 |
46 |
8294400 |
|
2000 |
38150221 |
vjudge5 |
E |
May 13, 2018, 1:10 a.m. |
OK |
GNU C++ |
TESTS |
61 |
46 |
8294400 |
|
2000 |
18223064 |
abhi1agarwal |
E |
June 2, 2016, 8:30 p.m. |
OK |
GNU C++ |
TESTS |
61 |
46 |
11161600 |
|
2000 |
18223033 |
abhi1agarwal |
E |
June 2, 2016, 8:27 p.m. |
OK |
GNU C++ |
TESTS |
61 |
46 |
11161600 |
|
2000 |
38150628 |
vjudge3 |
E |
May 13, 2018, 2:01 a.m. |
OK |
GNU C++ |
TESTS |
61 |
46 |
224256000 |
|
2000 |
38204010 |
vjudge5 |
E |
May 14, 2018, 2:28 a.m. |
OK |
GNU C++ |
TESTS |
61 |
61 |
3788800 |
|
2000 |
38202612 |
vjudge5 |
E |
May 13, 2018, 11:43 p.m. |
OK |
GNU C++ |
TESTS |
61 |
61 |
3788800 |
|
2000 |
38421488 |
vjudge1 |
E |
May 19, 2018, 7:32 a.m. |
OK |
GNU C++ |
TESTS |
61 |
62 |
204800 |
|
2000 |
32486547 |
memfault |
E |
Nov. 20, 2017, 12:20 a.m. |
OK |
GNU C11 |
TESTS |
61 |
77 |
1945600 |
|
2000 |
58960404 |
rainboy |
E |
Aug. 17, 2019, 2:57 p.m. |
OK |
GNU C11 |
TESTS |
61 |
109 |
0 |
|
2000 |
54013602 |
mcqueen1 |
E |
May 12, 2019, 4:58 a.m. |
OK |
GNU C++11 |
TESTS |
61 |
31 |
4096000 |
|
2000 |
14669140 |
Mrym.Rhmni |
E |
Dec. 5, 2015, 8:42 p.m. |
OK |
GNU C++11 |
TESTS |
61 |
31 |
5632000 |
|
2000 |
18070720 |
apoorv_kulsh |
E |
May 25, 2016, 12:05 p.m. |
OK |
GNU C++11 |
TESTS |
61 |
31 |
6553600 |
|
2000 |
68047737 |
noble |
E |
Jan. 1, 2020, 5:15 p.m. |
OK |
GNU C++11 |
TESTS |
61 |
46 |
102400 |
|
2000 |
63957813 |
luogu_bot4 |
E |
Nov. 1, 2019, 3:11 a.m. |
OK |
GNU C++11 |
TESTS |
61 |
46 |
204800 |
|
2000 |
24095920 |
y_shindoh |
E |
Jan. 24, 2017, 4:59 p.m. |
OK |
GNU C++11 |
TESTS |
61 |
46 |
1945600 |
|
2000 |
62040666 |
Kaeya |
E |
Oct. 7, 2019, 5:51 a.m. |
OK |
GNU C++11 |
TESTS |
61 |
46 |
4096000 |
|
2000 |
69985038 |
FerThugGato125 |
E |
Feb. 1, 2020, 5:34 p.m. |
OK |
GNU C++11 |
TESTS |
61 |
46 |
4198400 |
|
2000 |
40991890 |
ReaLNero1 |
E |
July 31, 2018, 12:56 a.m. |
OK |
GNU C++11 |
TESTS |
61 |
46 |
4300800 |
|
2000 |
14669157 |
Mrym.Rhmni |
E |
Dec. 5, 2015, 8:45 p.m. |
OK |
GNU C++11 |
TESTS |
61 |
46 |
5632000 |
|
2000 |
25480947 |
unused |
E |
March 14, 2017, 3:50 p.m. |
OK |
GNU C++14 |
TESTS |
61 |
31 |
7372800 |
|
2000 |
27879640 |
hzcong |
E |
June 18, 2017, 8:04 a.m. |
OK |
GNU C++14 |
TESTS |
61 |
46 |
4300800 |
|
2000 |
29531092 |
2390_ |
E |
Aug. 17, 2017, 4:59 p.m. |
OK |
GNU C++14 |
TESTS |
61 |
46 |
4300800 |
|
2000 |
27880846 |
hzcong |
E |
June 18, 2017, 9:02 a.m. |
OK |
GNU C++14 |
TESTS |
61 |
46 |
4403200 |
|
2000 |
52805808 |
sanketrai |
E |
April 16, 2019, 4:19 a.m. |
OK |
GNU C++14 |
TESTS |
61 |
46 |
4505600 |
|
2000 |
68112005 |
Gaunt |
E |
Jan. 3, 2020, 9:55 a.m. |
OK |
GNU C++14 |
TESTS |
61 |
46 |
4915200 |
|
2000 |
59653737 |
Jeffrey |
E |
Aug. 29, 2019, 9:24 a.m. |
OK |
GNU C++14 |
TESTS |
61 |
61 |
4096000 |
|
2000 |
56488501 |
asfd221 |
E |
July 3, 2019, 7:50 p.m. |
OK |
GNU C++14 |
TESTS |
61 |
61 |
4300800 |
|
2000 |
50601420 |
cant_worse_more |
E |
Feb. 28, 2019, 12:52 p.m. |
OK |
GNU C++14 |
TESTS |
61 |
61 |
4300800 |
|
2000 |
27879533 |
hzcong |
E |
June 18, 2017, 7:57 a.m. |
OK |
GNU C++14 |
TESTS |
61 |
61 |
4300800 |
|
2000 |
59914193 |
vjudge5 |
E |
Sept. 2, 2019, 6:26 p.m. |
OK |
GNU C++17 |
TESTS |
61 |
46 |
4300800 |
|
2000 |
64745026 |
JBer |
E |
Nov. 12, 2019, 1:15 p.m. |
OK |
GNU C++17 |
TESTS |
61 |
46 |
4505600 |
|
2000 |
66967845 |
vjudge5 |
E |
Dec. 15, 2019, 12:21 p.m. |
OK |
GNU C++17 |
TESTS |
61 |
46 |
4505600 |
|
2000 |
54378270 |
janezb |
E |
May 19, 2019, 9:43 a.m. |
OK |
GNU C++17 |
TESTS |
61 |
61 |
102400 |
|
2000 |
67509070 |
BRs82 |
E |
Dec. 24, 2019, 8:29 a.m. |
OK |
GNU C++17 |
TESTS |
61 |
61 |
4198400 |
|
2000 |
60260686 |
thantrongtri3 |
E |
Sept. 8, 2019, 11:21 a.m. |
OK |
GNU C++17 |
TESTS |
61 |
61 |
5324800 |
|
2000 |
50604845 |
vjudge2 |
E |
Feb. 28, 2019, 2:08 p.m. |
OK |
GNU C++17 |
TESTS |
61 |
62 |
3993600 |
|
2000 |
62056336 |
rohamizadidoost |
E |
Oct. 7, 2019, 12:12 p.m. |
OK |
GNU C++17 |
TESTS |
61 |
62 |
4300800 |
|
2000 |
58957740 |
Lixiangfan |
E |
Aug. 17, 2019, 1:46 p.m. |
OK |
GNU C++17 |
TESTS |
61 |
62 |
8806400 |
|
2000 |
50604252 |
Asagami |
E |
Feb. 28, 2019, 1:55 p.m. |
OK |
GNU C++17 |
TESTS |
61 |
77 |
3993600 |
|
2000 |
53992874 |
Hemose |
E |
May 11, 2019, 1:06 p.m. |
OK |
Java 8 |
TESTS |
61 |
311 |
0 |
|
2000 |
65692311 |
FluffyPotato |
E |
Nov. 25, 2019, 5:48 a.m. |
OK |
Java 8 |
TESTS |
61 |
311 |
4505600 |
|
2000 |
37260489 |
parth_15 |
E |
April 12, 2018, 9:04 p.m. |
OK |
Java 8 |
TESTS |
61 |
311 |
20684800 |
|
2000 |
68884717 |
adarsh000321 |
E |
Jan. 15, 2020, 8:33 p.m. |
OK |
Java 8 |
TESTS |
61 |
312 |
0 |
|
2000 |
49562299 |
Hoda_Hisham |
E |
Feb. 7, 2019, 1:12 p.m. |
OK |
Java 8 |
TESTS |
61 |
327 |
5529600 |
|
2000 |
26034421 |
GrEedWish_X |
E |
March 31, 2017, 7:48 p.m. |
OK |
Java 8 |
TESTS |
61 |
358 |
21913600 |
|
2000 |
58960405 |
Dukkha |
E |
Aug. 17, 2019, 2:57 p.m. |
OK |
Java 8 |
TESTS |
61 |
373 |
0 |
|
2000 |
39426957 |
bluesky111 |
E |
June 20, 2018, 5:38 a.m. |
OK |
Java 8 |
TESTS |
61 |
389 |
0 |
|
2000 |
27717172 |
Already |
E |
June 11, 2017, 8:03 a.m. |
OK |
Java 8 |
TESTS |
61 |
390 |
0 |
|
2000 |
33374486 |
aminul |
E |
Dec. 18, 2017, 9:54 a.m. |
OK |
Java 8 |
TESTS |
61 |
405 |
20684800 |
|
2000 |
26918701 |
og.kostya |
E |
May 7, 2017, 7:59 a.m. |
OK |
MS C# |
TESTS |
61 |
218 |
5427200 |
|
2000 |
45675561 |
vjudge3 |
E |
Nov. 13, 2018, 12:57 p.m. |
OK |
MS C++ |
TESTS |
61 |
124 |
307200 |
|
2000 |
58207252 |
vjudge5 |
E |
Aug. 3, 2019, 7:30 a.m. |
OK |
MS C++ |
TESTS |
61 |
124 |
4505600 |
|
2000 |
59883407 |
vjudge5 |
E |
Sept. 2, 2019, 6:30 a.m. |
OK |
MS C++ |
TESTS |
61 |
124 |
9420800 |
|
2000 |
15675686 |
Samsam |
E |
Jan. 30, 2016, 9:11 a.m. |
OK |
MS C++ |
TESTS |
61 |
140 |
4198400 |
|
2000 |
20100184 |
vjudge3 |
E |
Aug. 24, 2016, 7:18 a.m. |
OK |
MS C++ |
TESTS |
61 |
140 |
6656000 |
|
2000 |
20100170 |
vjudge5 |
E |
Aug. 24, 2016, 7:17 a.m. |
OK |
MS C++ |
TESTS |
61 |
155 |
6656000 |
|
2000 |
43553244 |
vjudge3 |
E |
Sept. 29, 2018, 3:30 a.m. |
OK |
MS C++ |
TESTS |
61 |
156 |
204800 |
|
2000 |
28462163 |
vjudge3 |
E |
July 12, 2017, 5:23 a.m. |
OK |
MS C++ |
TESTS |
61 |
156 |
2150400 |
|
2000 |
31943503 |
vjudge2 |
E |
Nov. 1, 2017, 8:54 a.m. |
OK |
MS C++ |
TESTS |
61 |
156 |
4300800 |
|
2000 |
55616760 |
vjudge5 |
E |
June 16, 2019, 9:27 a.m. |
OK |
MS C++ |
TESTS |
61 |
156 |
4403200 |
|
2000 |
62040728 |
vjudge4 |
E |
Oct. 7, 2019, 5:52 a.m. |
OK |
MS C++ 2017 |
TESTS |
61 |
61 |
4198400 |
|
2000 |
55058155 |
antofik |
E |
June 3, 2019, 8:09 p.m. |
OK |
MS C++ 2017 |
TESTS |
61 |
187 |
204800 |
|
2000 |
54975990 |
codeshaker |
E |
June 2, 2019, 10:50 a.m. |
OK |
MS C++ 2017 |
TESTS |
61 |
312 |
4300800 |
|
2000 |
52521483 |
pajenegod |
E |
April 9, 2019, 8:58 a.m. |
OK |
PyPy 3 |
TESTS |
61 |
545 |
1228800 |
|
2000 |
52522293 |
pajenegod |
E |
April 9, 2019, 9:27 a.m. |
OK |
PyPy 3 |
TESTS |
61 |
545 |
1433600 |
|
2000 |
52522253 |
pajenegod |
E |
April 9, 2019, 9:26 a.m. |
OK |
PyPy 3 |
TESTS |
61 |
545 |
1433600 |
|
2000 |
52522059 |
pajenegod |
E |
April 9, 2019, 9:19 a.m. |
OK |
PyPy 3 |
TESTS |
61 |
561 |
1536000 |
|
2000 |
52522103 |
pajenegod |
E |
April 9, 2019, 9:21 a.m. |
OK |
PyPy 3 |
TESTS |
61 |
608 |
1228800 |
|
2000 |
52515251 |
meooow |
E |
April 9, 2019, 4:45 a.m. |
OK |
PyPy 3 |
TESTS |
61 |
732 |
1433600 |
|
2000 |
31772595 |
yugle7 |
E |
Oct. 26, 2017, 8:41 p.m. |
OK |
PyPy 3 |
TESTS |
61 |
811 |
5222400 |
|
2000 |
52516097 |
c1729 |
E |
April 9, 2019, 5:31 a.m. |
OK |
PyPy 3 |
TESTS |
61 |
935 |
1228800 |
|
2000 |
31773177 |
yugle7 |
E |
Oct. 26, 2017, 9:12 p.m. |
OK |
PyPy 3 |
TESTS |
61 |
998 |
5734400 |
|
2000 |
31772741 |
yugle7 |
E |
Oct. 26, 2017, 8:49 p.m. |
OK |
PyPy 3 |
TESTS |
61 |
998 |
5734400 |
|
2000 |
remove filters
Back to search problems