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'Ivan has n different boxes. The first of them contains some balls of n different colors. Ivan wants to play a strange game. He wants to distribute the balls into boxes in such a way that for every i (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89i xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n) i-th box will contain all balls with color i. In order to do this, Ivan will make some turns. Each turn he does the following: The penalty of the turn is the number of balls Ivan takes from the box during the first step of the turn. And penalty of the game is the total penalty of turns made by Ivan until he distributes all balls to corresponding boxes. Help Ivan to determine the minimum possible penalty of the game! The first line contains one integer number n (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89200000) -- the number of boxes and colors. The second line contains n integer numbers a1, a2, ..., an (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89ai xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89109), where ai is the number of balls with color i. Print one number -- the minimum possible penalty of the game. In the first example you take all the balls from the first box, choose k xe2 x80 x89= xe2 x80 x893 and sort all colors to corresponding boxes. Penalty is 6. In the second example you make two turns: Total penalty is 19. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
32007918 |
Faimerth |
D |
Nov. 3, 2017, 1:04 p.m. |
OK |
GNU C |
TESTS |
32 |
124 |
7987200 |
|
2300 |
31807349 |
MSF_Akatsuki |
D |
Oct. 27, 2017, 3:16 p.m. |
OK |
GNU C++ |
TESTS |
32 |
62 |
2969600 |
|
2300 |
31899983 |
wzp666 |
D |
Oct. 30, 2017, 4:41 p.m. |
OK |
GNU C++ |
TESTS |
32 |
62 |
3174400 |
|
2300 |
31922253 |
yafi38 |
D |
Oct. 31, 2017, 1:12 p.m. |
OK |
GNU C++ |
TESTS |
32 |
62 |
3174400 |
|
2300 |
33473877 |
Thefinal |
D |
Dec. 21, 2017, 8:22 a.m. |
OK |
GNU C++ |
TESTS |
32 |
62 |
3788800 |
|
2300 |
33651696 |
khatribiru |
D |
Dec. 26, 2017, 4:21 p.m. |
OK |
GNU C++ |
TESTS |
32 |
62 |
6860800 |
|
2300 |
32003682 |
shiyilang |
D |
Nov. 3, 2017, 10 a.m. |
OK |
GNU C++ |
TESTS |
32 |
77 |
3174400 |
|
2300 |
31972128 |
Scut82 |
D |
Nov. 2, 2017, 8:28 a.m. |
OK |
GNU C++ |
TESTS |
32 |
77 |
3174400 |
|
2300 |
31810529 |
lzr_010506 |
D |
Oct. 27, 2017, 3:58 p.m. |
OK |
GNU C++ |
TESTS |
32 |
77 |
3993600 |
|
2300 |
31856101 |
weng_233 |
D |
Oct. 29, 2017, 5:04 a.m. |
OK |
GNU C++ |
TESTS |
32 |
93 |
2969600 |
|
2300 |
32349350 |
tangbingchang |
D |
Nov. 16, 2017, 7:36 a.m. |
OK |
GNU C++ |
TESTS |
32 |
93 |
3174400 |
|
2300 |
53203988 |
rainboy |
D |
April 23, 2019, 7:48 p.m. |
OK |
GNU C11 |
TESTS |
32 |
124 |
3993600 |
|
2300 |
48785786 |
Mly |
D |
Jan. 23, 2019, 8:53 a.m. |
OK |
GNU C++11 |
TESTS |
32 |
62 |
1433600 |
|
2300 |
58080660 |
TianPingXing |
D |
July 31, 2019, 1:48 p.m. |
OK |
GNU C++11 |
TESTS |
32 |
62 |
1638400 |
|
2300 |
58080685 |
wangkr |
D |
July 31, 2019, 1:48 p.m. |
OK |
GNU C++11 |
TESTS |
32 |
62 |
1638400 |
|
2300 |
32064015 |
krijgertje |
D |
Nov. 4, 2017, 9:22 p.m. |
OK |
GNU C++11 |
TESTS |
32 |
62 |
2457600 |
|
2300 |
65994368 |
lzht |
D |
Nov. 29, 2019, 5:18 p.m. |
OK |
GNU C++11 |
TESTS |
32 |
62 |
3174400 |
|
2300 |
57986325 |
TianZuiXing |
D |
July 30, 2019, 11:31 a.m. |
OK |
GNU C++11 |
TESTS |
32 |
62 |
3174400 |
|
2300 |
48029056 |
menjiantong |
D |
Jan. 6, 2019, 11:10 a.m. |
OK |
GNU C++11 |
TESTS |
32 |
62 |
3174400 |
|
2300 |
65997247 |
vjudge4 |
D |
Nov. 29, 2019, 5:56 p.m. |
OK |
GNU C++11 |
TESTS |
32 |
62 |
3174400 |
|
2300 |
46673977 |
wzj_xhjbk |
D |
Dec. 6, 2018, 8:41 a.m. |
OK |
GNU C++11 |
TESTS |
32 |
62 |
3174400 |
|
2300 |
46927870 |
LJC00118 |
D |
Dec. 12, 2018, 9:52 a.m. |
OK |
GNU C++11 |
TESTS |
32 |
62 |
3174400 |
|
2300 |
31908011 |
flukehn |
D |
Oct. 31, 2017, 12:16 a.m. |
OK |
GNU C++14 |
TESTS |
32 |
62 |
3276800 |
|
2300 |
32135635 |
FizzyDavid |
D |
Nov. 8, 2017, 9:13 a.m. |
OK |
GNU C++14 |
TESTS |
32 |
62 |
3276800 |
|
2300 |
31970717 |
zuzhiang |
D |
Nov. 2, 2017, 7:24 a.m. |
OK |
GNU C++14 |
TESTS |
32 |
93 |
3174400 |
|
2300 |
32068013 |
1627405131_ws |
D |
Nov. 5, 2017, 4:58 a.m. |
OK |
GNU C++14 |
TESTS |
32 |
93 |
3174400 |
|
2300 |
31936761 |
snowy_smile |
D |
Nov. 1, 2017, 2:29 a.m. |
OK |
GNU C++14 |
TESTS |
32 |
93 |
3174400 |
|
2300 |
31825484 |
Tbuji |
D |
Oct. 28, 2017, 5:48 a.m. |
OK |
GNU C++14 |
TESTS |
32 |
93 |
3174400 |
|
2300 |
31818412 |
Hasan0540 |
D |
Oct. 27, 2017, 8:09 p.m. |
OK |
GNU C++14 |
TESTS |
32 |
93 |
3174400 |
|
2300 |
31812081 |
baluteshih |
D |
Oct. 27, 2017, 4:26 p.m. |
OK |
GNU C++14 |
TESTS |
32 |
93 |
3174400 |
|
2300 |
32418710 |
chen_assert |
D |
Nov. 18, 2017, 2:48 a.m. |
OK |
GNU C++14 |
TESTS |
32 |
93 |
4812800 |
|
2300 |
32245445 |
gs15120 |
D |
Nov. 12, 2017, 2:01 p.m. |
OK |
GNU C++14 |
TESTS |
32 |
93 |
109977600 |
|
2300 |
58103881 |
TianJianXing |
D |
Aug. 1, 2019, 2:55 a.m. |
OK |
GNU C++17 |
TESTS |
32 |
108 |
3174400 |
|
2300 |
58104942 |
TianJianXing |
D |
Aug. 1, 2019, 3:35 a.m. |
OK |
GNU C++17 |
TESTS |
32 |
108 |
3174400 |
|
2300 |
58103975 |
TianZuiXing |
D |
Aug. 1, 2019, 2:59 a.m. |
OK |
GNU C++17 |
TESTS |
32 |
108 |
3174400 |
|
2300 |
58103419 |
TianSunXing |
D |
Aug. 1, 2019, 2:36 a.m. |
OK |
GNU C++17 |
TESTS |
32 |
109 |
3174400 |
|
2300 |
58101952 |
TianSunXing |
D |
Aug. 1, 2019, 1:38 a.m. |
OK |
GNU C++17 |
TESTS |
32 |
109 |
3174400 |
|
2300 |
44881929 |
Hassanosama |
D |
Oct. 25, 2018, 7:33 p.m. |
OK |
GNU C++17 |
TESTS |
32 |
109 |
3174400 |
|
2300 |
59118357 |
spectaclehong |
D |
Aug. 20, 2019, 3:12 a.m. |
OK |
GNU C++17 |
TESTS |
32 |
109 |
3174400 |
|
2300 |
57631411 |
465798176 |
D |
July 24, 2019, 8:52 a.m. |
OK |
GNU C++17 |
TESTS |
32 |
124 |
2355200 |
|
2300 |
69596081 |
aryanc403 |
D |
Jan. 27, 2020, 4:51 a.m. |
OK |
GNU C++17 |
TESTS |
32 |
124 |
3174400 |
|
2300 |
67375922 |
_PortgasD.Ace_ |
D |
Dec. 21, 2019, 3:04 p.m. |
OK |
GNU C++17 |
TESTS |
32 |
124 |
3174400 |
|
2300 |
31896128 |
mipt.vi002 |
D |
Oct. 30, 2017, 2:11 p.m. |
OK |
Haskell |
TESTS |
32 |
701 |
47513600 |
|
2300 |
31896081 |
mipt.vi002 |
D |
Oct. 30, 2017, 2:09 p.m. |
OK |
Haskell |
TESTS |
32 |
702 |
47513600 |
|
2300 |
31894539 |
mipt.vi002 |
D |
Oct. 30, 2017, 1:17 p.m. |
OK |
Haskell |
TESTS |
32 |
920 |
49561600 |
|
2300 |
32176832 |
shreyansh97 |
D |
Nov. 9, 2017, 5:59 p.m. |
OK |
Java 8 |
TESTS |
32 |
265 |
0 |
|
2300 |
32034550 |
olya-chuchuk |
D |
Nov. 3, 2017, 6:58 p.m. |
OK |
Java 8 |
TESTS |
32 |
280 |
0 |
|
2300 |
31816185 |
tyuan73 |
D |
Oct. 27, 2017, 6:36 p.m. |
OK |
Java 8 |
TESTS |
32 |
280 |
0 |
|
2300 |
34957470 |
svilen |
D |
Feb. 6, 2018, 12:02 a.m. |
OK |
Java 8 |
TESTS |
32 |
295 |
20684800 |
|
2300 |
31829670 |
uwi |
D |
Oct. 28, 2017, 8:50 a.m. |
OK |
Java 8 |
TESTS |
32 |
296 |
0 |
|
2300 |
32157584 |
wolfor |
D |
Nov. 9, 2017, 12:29 p.m. |
OK |
Java 8 |
TESTS |
32 |
311 |
0 |
|
2300 |
58062478 |
TianZuiXing |
D |
July 31, 2019, 7:53 a.m. |
OK |
Java 8 |
TESTS |
32 |
311 |
4198400 |
|
2300 |
53185138 |
aman28rwt |
D |
April 23, 2019, 9:53 a.m. |
OK |
Java 8 |
TESTS |
32 |
327 |
0 |
|
2300 |
32333924 |
parth_15 |
D |
Nov. 15, 2017, 2:06 p.m. |
OK |
Java 8 |
TESTS |
32 |
327 |
0 |
|
2300 |
31908522 |
KirillxIonov |
D |
Oct. 31, 2017, 1:11 a.m. |
OK |
Java 8 |
TESTS |
32 |
327 |
4096000 |
|
2300 |
31819751 |
serejkee |
D |
Oct. 27, 2017, 9:30 p.m. |
OK |
Kotlin |
TESTS |
32 |
389 |
5120000 |
|
2300 |
31813502 |
ldt116 |
D |
Oct. 27, 2017, 5:06 p.m. |
OK |
Kotlin |
TESTS |
32 |
389 |
5939200 |
|
2300 |
31965543 |
unused |
D |
Nov. 2, 2017, 12:54 a.m. |
OK |
MS C# |
TESTS |
32 |
202 |
5222400 |
|
2300 |
32526497 |
pixxxelolo |
D |
Nov. 21, 2017, 1:24 p.m. |
OK |
MS C++ |
TESTS |
32 |
78 |
4812800 |
|
2300 |
66160378 |
vjudge3 |
D |
Dec. 2, 2019, 3:53 a.m. |
OK |
MS C++ |
TESTS |
32 |
93 |
3276800 |
|
2300 |
66088798 |
vjudge3 |
D |
Dec. 1, 2019, 6:23 a.m. |
OK |
MS C++ |
TESTS |
32 |
93 |
3276800 |
|
2300 |
65909453 |
vjudge3 |
D |
Nov. 28, 2019, 12:20 p.m. |
OK |
MS C++ |
TESTS |
32 |
93 |
3276800 |
|
2300 |
32494339 |
oraheem |
D |
Nov. 20, 2017, 9:14 a.m. |
OK |
MS C++ |
TESTS |
32 |
93 |
3276800 |
|
2300 |
65875966 |
vjudge2 |
D |
Nov. 27, 2019, 5:01 p.m. |
OK |
MS C++ |
TESTS |
32 |
93 |
4096000 |
|
2300 |
66088690 |
vjudge2 |
D |
Dec. 1, 2019, 6:20 a.m. |
OK |
MS C++ |
TESTS |
32 |
93 |
4915200 |
|
2300 |
66049597 |
vjudge2 |
D |
Nov. 30, 2019, 4:36 p.m. |
OK |
MS C++ |
TESTS |
32 |
93 |
4915200 |
|
2300 |
66049429 |
bestlzk_2000aeon |
D |
Nov. 30, 2019, 4:31 p.m. |
OK |
MS C++ |
TESTS |
32 |
93 |
4915200 |
|
2300 |
65946262 |
vjudge5 |
D |
Nov. 29, 2019, 8:47 a.m. |
OK |
MS C++ |
TESTS |
32 |
93 |
4915200 |
|
2300 |
65937189 |
MisakiMikoto |
D |
Nov. 29, 2019, 3:14 a.m. |
OK |
MS C++ 2017 |
TESTS |
32 |
249 |
2764800 |
|
2300 |
66029661 |
vjudge2 |
D |
Nov. 30, 2019, 9:44 a.m. |
OK |
MS C++ 2017 |
TESTS |
32 |
280 |
2764800 |
|
2300 |
65948101 |
vjudge3 |
D |
Nov. 29, 2019, 9:35 a.m. |
OK |
MS C++ 2017 |
TESTS |
32 |
296 |
7577600 |
|
2300 |
35129819 |
abhigyank |
D |
Feb. 10, 2018, 3:36 p.m. |
OK |
PyPy 2 |
TESTS |
32 |
1138 |
35942400 |
|
2300 |
31807399 |
mmaxio |
D |
Oct. 27, 2017, 3:17 p.m. |
OK |
PyPy 3 |
TESTS |
32 |
1294 |
20684800 |
|
2300 |
32006896 |
siddharth.s.atwork |
D |
Nov. 3, 2017, 12:18 p.m. |
OK |
PyPy 3 |
TESTS |
32 |
1450 |
20480000 |
|
2300 |
39047022 |
madn |
D |
June 8, 2018, 1:12 p.m. |
OK |
PyPy 3 |
TESTS |
32 |
1668 |
27852800 |
|
2300 |
48330848 |
introibo |
D |
Jan. 13, 2019, 2:19 p.m. |
OK |
Python 2 |
TESTS |
32 |
1341 |
11059200 |
|
2300 |
48330670 |
introibo |
D |
Jan. 13, 2019, 2:14 p.m. |
OK |
Python 2 |
TESTS |
32 |
1356 |
11059200 |
|
2300 |
48335416 |
introibo |
D |
Jan. 13, 2019, 2:49 p.m. |
OK |
Python 2 |
TESTS |
32 |
1590 |
11059200 |
|
2300 |
48337775 |
introibo |
D |
Jan. 13, 2019, 2:56 p.m. |
OK |
Python 2 |
TESTS |
32 |
1591 |
11059200 |
|
2300 |
58105430 |
TianZuiXing |
D |
Aug. 1, 2019, 3:55 a.m. |
OK |
Python 2 |
TESTS |
32 |
1606 |
11878400 |
|
2300 |
31974120 |
franckmy |
D |
Nov. 2, 2017, 9:45 a.m. |
OK |
Python 2 |
TESTS |
32 |
1746 |
11264000 |
|
2300 |
32209653 |
Tconan |
D |
Nov. 11, 2017, 3:33 a.m. |
OK |
Python 2 |
TESTS |
32 |
1747 |
11980800 |
|
2300 |
39403279 |
Ali_Pi |
D |
June 19, 2018, 8:19 a.m. |
OK |
Python 2 |
TESTS |
32 |
1793 |
12288000 |
|
2300 |
31815821 |
wangkan2001 |
D |
Oct. 27, 2017, 6:24 p.m. |
OK |
Python 2 |
TESTS |
32 |
1809 |
11264000 |
|
2300 |
31860092 |
Taxman |
D |
Oct. 29, 2017, 8:19 a.m. |
OK |
Python 2 |
TESTS |
32 |
1840 |
11059200 |
|
2300 |
32036042 |
atryapa |
D |
Nov. 3, 2017, 8:11 p.m. |
OK |
Python 3 |
TESTS |
32 |
405 |
16486400 |
|
2300 |
31877670 |
NiakTheWizard |
D |
Oct. 29, 2017, 9:38 p.m. |
OK |
Python 3 |
TESTS |
32 |
420 |
16486400 |
|
2300 |
31817509 |
JustN |
D |
Oct. 27, 2017, 7:27 p.m. |
OK |
Python 3 |
TESTS |
32 |
451 |
16486400 |
|
2300 |
32042130 |
LegitinateAlex |
D |
Nov. 4, 2017, 4:26 a.m. |
OK |
Python 3 |
TESTS |
32 |
452 |
16486400 |
|
2300 |
53182517 |
meooow |
D |
April 23, 2019, 8:25 a.m. |
OK |
Python 3 |
TESTS |
32 |
452 |
16588800 |
|
2300 |
32019579 |
Anastassija |
D |
Nov. 3, 2017, 4:30 p.m. |
OK |
Python 3 |
TESTS |
32 |
467 |
16486400 |
|
2300 |
31936895 |
Tracing |
D |
Nov. 1, 2017, 2:45 a.m. |
OK |
Python 3 |
TESTS |
32 |
467 |
16486400 |
|
2300 |
31812698 |
USEaglE |
D |
Oct. 27, 2017, 4:42 p.m. |
OK |
Python 3 |
TESTS |
32 |
467 |
16486400 |
|
2300 |
32031320 |
genocid |
D |
Nov. 3, 2017, 6 p.m. |
OK |
Python 3 |
TESTS |
32 |
483 |
15360000 |
|
2300 |
31979243 |
StinsonOvO |
D |
Nov. 2, 2017, 12:16 p.m. |
OK |
Python 3 |
TESTS |
32 |
483 |
15769600 |
|
2300 |
32306101 |
hatoo |
D |
Nov. 14, 2017, 7:55 a.m. |
OK |
Rust |
TESTS |
32 |
93 |
6860800 |
|
2300 |
remove filters
Back to search problems