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 a of n integers, such that a_1 + a_2 + cdots + a_n = 0 . In one operation, you can choose two different indices i and j ( 1 <= i, j <= n ), decrement a_i by one and increment a_j by one. If i < j this operation is free, otherwise it costs one coin. How many coins do you have to spend in order to make all elements equal to 0 ? Each test contains multiple test cases. The first line contains the number of test cases t ( 1 <= t <= 5000 ). Description of the test cases follows. The first line of each test case contains an integer n ( 1 <= n <= 10^5 ) -- the number of elements. The next line contains n integers a_1, ldots, a_n ( -10^9 <= a_i <= 10^9 ). It is given that sum_{i=1}^n a_i = 0 . It is guaranteed that the sum of n over all test cases does not exceed 10^5 . For each test case, print the minimum number of coins we have to spend in order to make all elements equal to 0 . Possible strategy for the first test case: "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
92097347 |
Vicfred |
B |
Sept. 7, 2020, 1:52 a.m. |
OK |
D |
TESTS |
31 |
62 |
6144000 |
|
|
92081274 |
aebtll |
B |
Sept. 6, 2020, 5:59 p.m. |
OK |
GNU C11 |
TESTS |
31 |
46 |
0 |
|
|
92099853 |
eugalt |
B |
Sept. 7, 2020, 3:05 a.m. |
OK |
GNU C11 |
TESTS |
31 |
46 |
0 |
|
|
92100084 |
eugalt |
B |
Sept. 7, 2020, 3:12 a.m. |
OK |
GNU C11 |
TESTS |
31 |
46 |
0 |
|
|
92071024 |
Lorin_zeba |
B |
Sept. 6, 2020, 4:25 p.m. |
OK |
GNU C11 |
TESTS |
21 |
62 |
0 |
|
|
92067016 |
Iizshit |
B |
Sept. 6, 2020, 4:11 p.m. |
OK |
GNU C11 |
TESTS |
21 |
62 |
409600 |
|
|
92091733 |
babaiserror |
B |
Sept. 6, 2020, 9:39 p.m. |
OK |
GNU C11 |
TESTS |
31 |
62 |
819200 |
|
|
92070850 |
nitinkumar1729 |
B |
Sept. 6, 2020, 4:24 p.m. |
OK |
GNU C11 |
TESTS |
21 |
62 |
819200 |
|
|
92072696 |
curioquisitive |
B |
Sept. 6, 2020, 4:30 p.m. |
OK |
GNU C11 |
TESTS |
21 |
62 |
819200 |
|
|
92067291 |
rathabhi |
B |
Sept. 6, 2020, 4:12 p.m. |
OK |
GNU C11 |
TESTS |
21 |
62 |
7987200 |
|
|
92066685 |
jeevanyasa_04 |
B |
Sept. 6, 2020, 4:10 p.m. |
OK |
GNU C11 |
TESTS |
21 |
62 |
7987200 |
|
|
92095989 |
kimyon |
B |
Sept. 7, 2020, 1:02 a.m. |
OK |
GNU C++11 |
TESTS |
31 |
31 |
819200 |
|
|
92099406 |
YHHxBULIATANIA |
B |
Sept. 7, 2020, 2:53 a.m. |
OK |
GNU C++11 |
TESTS |
31 |
31 |
1638400 |
|
|
92063666 |
Fuko_Ibuki |
B |
Sept. 6, 2020, 3:59 p.m. |
OK |
GNU C++11 |
TESTS |
21 |
31 |
8806400 |
|
|
92062827 |
spider_void |
B |
Sept. 6, 2020, 3:57 p.m. |
OK |
GNU C++11 |
TESTS |
21 |
46 |
0 |
|
|
92068123 |
G00dCOD3R |
B |
Sept. 6, 2020, 4:15 p.m. |
OK |
GNU C++11 |
TESTS |
21 |
46 |
0 |
|
|
92100287 |
convicnow |
B |
Sept. 7, 2020, 3:17 a.m. |
OK |
GNU C++11 |
TESTS |
31 |
46 |
0 |
|
|
92100300 |
autistic_boy |
B |
Sept. 7, 2020, 3:18 a.m. |
OK |
GNU C++11 |
TESTS |
31 |
46 |
0 |
|
|
92097580 |
poplpr |
B |
Sept. 7, 2020, 2 a.m. |
OK |
GNU C++11 |
TESTS |
31 |
46 |
204800 |
|
|
92108456 |
worcher |
B |
Sept. 7, 2020, 5:59 a.m. |
OK |
GNU C++11 |
TESTS |
31 |
46 |
409600 |
|
|
92106884 |
orrz |
B |
Sept. 7, 2020, 5:32 a.m. |
OK |
GNU C++11 |
TESTS |
31 |
46 |
409600 |
|
|
92063700 |
Amaan_Farooq |
B |
Sept. 6, 2020, 3:59 p.m. |
OK |
GNU C++14 |
TESTS |
21 |
46 |
0 |
|
|
92079309 |
prayagrai.93 |
B |
Sept. 6, 2020, 5:37 p.m. |
OK |
GNU C++14 |
TESTS |
31 |
46 |
0 |
|
|
92084725 |
aditya1226 |
B |
Sept. 6, 2020, 6:50 p.m. |
OK |
GNU C++14 |
TESTS |
31 |
46 |
409600 |
|
|
92091245 |
mohamedelgendyx |
B |
Sept. 6, 2020, 9:22 p.m. |
OK |
GNU C++14 |
TESTS |
31 |
46 |
409600 |
|
|
92091276 |
Gendy_ |
B |
Sept. 6, 2020, 9:23 p.m. |
OK |
GNU C++14 |
TESTS |
31 |
46 |
409600 |
|
|
92101646 |
marcOS |
B |
Sept. 7, 2020, 3:51 a.m. |
OK |
GNU C++14 |
TESTS |
31 |
46 |
409600 |
|
|
92104833 |
Newplayers123 |
B |
Sept. 7, 2020, 4:57 a.m. |
OK |
GNU C++14 |
TESTS |
31 |
46 |
409600 |
|
|
92068257 |
meena26 |
B |
Sept. 6, 2020, 4:15 p.m. |
OK |
GNU C++14 |
TESTS |
21 |
46 |
409600 |
|
|
92070349 |
AbdallaMaher |
B |
Sept. 6, 2020, 4:22 p.m. |
OK |
GNU C++14 |
TESTS |
21 |
46 |
409600 |
|
|
92077153 |
Milo_Murphy |
B |
Sept. 6, 2020, 5:22 p.m. |
OK |
GNU C++14 |
TESTS |
21 |
46 |
409600 |
|
|
92063432 |
iamvinayvk |
B |
Sept. 6, 2020, 3:59 p.m. |
OK |
GNU C++17 |
TESTS |
21 |
46 |
0 |
|
|
92102713 |
Divyanshj_810 |
B |
Sept. 7, 2020, 4:14 a.m. |
OK |
GNU C++17 |
TESTS |
31 |
46 |
0 |
|
|
92072552 |
ekeshwarj5 |
B |
Sept. 6, 2020, 4:29 p.m. |
OK |
GNU C++17 |
TESTS |
21 |
46 |
0 |
|
|
92101409 |
Bennettz |
B |
Sept. 7, 2020, 3:46 a.m. |
OK |
GNU C++17 |
TESTS |
31 |
46 |
0 |
|
|
92084616 |
MilosMilutinovic371 |
B |
Sept. 6, 2020, 6:49 p.m. |
OK |
GNU C++17 |
TESTS |
31 |
46 |
409600 |
|
|
92104895 |
danielcm583 |
B |
Sept. 7, 2020, 4:58 a.m. |
OK |
GNU C++17 |
TESTS |
31 |
46 |
409600 |
|
|
92101313 |
Just_a_programmer |
B |
Sept. 7, 2020, 3:44 a.m. |
OK |
GNU C++17 |
TESTS |
31 |
46 |
409600 |
|
|
92099383 |
Rangerstorm |
B |
Sept. 7, 2020, 2:52 a.m. |
OK |
GNU C++17 |
TESTS |
31 |
46 |
409600 |
|
|
92098420 |
541907010414 |
B |
Sept. 7, 2020, 2:26 a.m. |
OK |
GNU C++17 |
TESTS |
31 |
46 |
409600 |
|
|
92092555 |
IsmailToukhy |
B |
Sept. 6, 2020, 10:10 p.m. |
OK |
GNU C++17 |
TESTS |
31 |
46 |
409600 |
|
|
92078901 |
Anish1712 |
B |
Sept. 6, 2020, 5:34 p.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
31 |
819200 |
|
|
92090955 |
Renaats |
B |
Sept. 6, 2020, 9:12 p.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
31 |
1843200 |
|
|
92083973 |
Ehab_Fawzy |
B |
Sept. 6, 2020, 6:39 p.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
31 |
2252800 |
|
|
92088901 |
aarav.cube |
B |
Sept. 6, 2020, 8:11 p.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
46 |
0 |
|
|
92101123 |
MN_Mind |
B |
Sept. 7, 2020, 3:39 a.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
46 |
0 |
|
|
92102440 |
Coder_SahajGupta |
B |
Sept. 7, 2020, 4:09 a.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
46 |
0 |
|
|
92106429 |
atharva_kulkarni69 |
B |
Sept. 7, 2020, 5:24 a.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
46 |
0 |
|
|
92079246 |
hungt1 |
B |
Sept. 6, 2020, 5:36 p.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
46 |
0 |
|
|
92082965 |
Monogon |
B |
Sept. 6, 2020, 6:23 p.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
46 |
0 |
|
|
92086455 |
aajisaka |
B |
Sept. 6, 2020, 7:21 p.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
46 |
0 |
|
|
92063296 |
skypper |
B |
Sept. 6, 2020, 3:58 p.m. |
OK |
Go |
TESTS |
21 |
93 |
819200 |
|
|
92085266 |
DreamInfinite |
B |
Sept. 6, 2020, 7 p.m. |
OK |
Java 11 |
TESTS |
31 |
171 |
0 |
|
|
92105057 |
sf14t |
B |
Sept. 7, 2020, 5:01 a.m. |
OK |
Java 11 |
TESTS |
31 |
202 |
0 |
|
|
92099855 |
kadintang1 |
B |
Sept. 7, 2020, 3:05 a.m. |
OK |
Java 11 |
TESTS |
31 |
202 |
0 |
|
|
92084472 |
dwoolley3 |
B |
Sept. 6, 2020, 6:47 p.m. |
OK |
Java 11 |
TESTS |
31 |
202 |
0 |
|
|
92083149 |
gssakash |
B |
Sept. 6, 2020, 6:26 p.m. |
OK |
Java 11 |
TESTS |
31 |
202 |
0 |
|
|
92080602 |
liubenjamin |
B |
Sept. 6, 2020, 5:50 p.m. |
OK |
Java 11 |
TESTS |
31 |
202 |
0 |
|
|
92080383 |
typewriter999 |
B |
Sept. 6, 2020, 5:48 p.m. |
OK |
Java 11 |
TESTS |
31 |
202 |
0 |
|
|
92073857 |
imrankhurshid94 |
B |
Sept. 6, 2020, 4:33 p.m. |
OK |
Java 11 |
TESTS |
21 |
202 |
0 |
|
|
92088621 |
_prophet |
B |
Sept. 6, 2020, 8:04 p.m. |
OK |
Java 11 |
TESTS |
31 |
217 |
0 |
|
|
92086198 |
Lior |
B |
Sept. 6, 2020, 7:16 p.m. |
OK |
Java 11 |
TESTS |
31 |
217 |
0 |
|
|
92091084 |
priyesh002 |
B |
Sept. 6, 2020, 9:16 p.m. |
OK |
Java 8 |
TESTS |
31 |
109 |
0 |
|
|
92078040 |
Manan8686 |
B |
Sept. 6, 2020, 5:27 p.m. |
OK |
Java 8 |
TESTS |
31 |
109 |
0 |
|
|
92082485 |
ashraybharambe |
B |
Sept. 6, 2020, 6:16 p.m. |
OK |
Java 8 |
TESTS |
31 |
124 |
0 |
|
|
92065781 |
karthickshiva1709 |
B |
Sept. 6, 2020, 4:07 p.m. |
OK |
Java 8 |
TESTS |
21 |
124 |
0 |
|
|
92087010 |
khalled_95 |
B |
Sept. 6, 2020, 7:32 p.m. |
OK |
Java 8 |
TESTS |
31 |
139 |
0 |
|
|
92082066 |
hars1234 |
B |
Sept. 6, 2020, 6:10 p.m. |
OK |
Java 8 |
TESTS |
31 |
139 |
0 |
|
|
92080751 |
akram-adel |
B |
Sept. 6, 2020, 5:52 p.m. |
OK |
Java 8 |
TESTS |
31 |
139 |
0 |
|
|
92079341 |
prem_cse |
B |
Sept. 6, 2020, 5:37 p.m. |
OK |
Java 8 |
TESTS |
31 |
139 |
0 |
|
|
92106369 |
bhavik128 |
B |
Sept. 7, 2020, 5:23 a.m. |
OK |
Java 8 |
TESTS |
31 |
140 |
0 |
|
|
92105112 |
priyam_anand |
B |
Sept. 7, 2020, 5:02 a.m. |
OK |
Java 8 |
TESTS |
31 |
140 |
0 |
|
|
92100082 |
Spheniscine |
B |
Sept. 7, 2020, 3:12 a.m. |
OK |
Kotlin |
TESTS |
31 |
140 |
0 |
|
|
92078771 |
koboshi |
B |
Sept. 6, 2020, 5:33 p.m. |
OK |
Kotlin |
TESTS |
31 |
171 |
102400 |
|
|
92082633 |
Mirimax |
B |
Sept. 6, 2020, 6:18 p.m. |
OK |
Kotlin |
TESTS |
31 |
187 |
0 |
|
|
92077938 |
Mallang |
B |
Sept. 6, 2020, 5:26 p.m. |
OK |
Kotlin |
TESTS |
31 |
265 |
6451200 |
|
|
92084432 |
azukun |
B |
Sept. 6, 2020, 6:46 p.m. |
OK |
Mono C# |
TESTS |
31 |
93 |
17100800 |
|
|
92071723 |
hhsaffar |
B |
Sept. 6, 2020, 4:27 p.m. |
OK |
Mono C# |
TESTS |
21 |
124 |
15564800 |
|
|
92064068 |
miruomiruomi |
B |
Sept. 6, 2020, 4:01 p.m. |
OK |
MS C++ |
TESTS |
21 |
46 |
819200 |
|
|
92087486 |
ustaritz |
B |
Sept. 6, 2020, 7:41 p.m. |
OK |
MS C++ 2017 |
TESTS |
31 |
124 |
409600 |
|
|
92079893 |
Gravekper |
B |
Sept. 6, 2020, 5:43 p.m. |
OK |
MS C++ 2017 |
TESTS |
31 |
124 |
409600 |
|
|
92091350 |
ustaritz |
B |
Sept. 6, 2020, 9:26 p.m. |
OK |
MS C++ 2017 |
TESTS |
31 |
124 |
409600 |
|
|
92085513 |
guneykan |
B |
Sept. 6, 2020, 7:04 p.m. |
OK |
MS C++ 2017 |
TESTS |
31 |
124 |
819200 |
|
|
92084890 |
DiSTRuCtO |
B |
Sept. 6, 2020, 6:53 p.m. |
OK |
MS C++ 2017 |
TESTS |
31 |
124 |
819200 |
|
|
92097718 |
s1lent.ssh |
B |
Sept. 7, 2020, 2:05 a.m. |
OK |
MS C++ 2017 |
TESTS |
31 |
124 |
3276800 |
|
|
92064361 |
Sam180252 |
B |
Sept. 6, 2020, 4:02 p.m. |
OK |
MS C++ 2017 |
TESTS |
21 |
139 |
409600 |
|
|
92072984 |
samcpp |
B |
Sept. 6, 2020, 4:31 p.m. |
OK |
MS C++ 2017 |
TESTS |
21 |
139 |
819200 |
|
|
92065567 |
qing_lin |
B |
Sept. 6, 2020, 4:06 p.m. |
OK |
MS C++ 2017 |
TESTS |
21 |
139 |
2457600 |
|
|
92073662 |
Haw00 |
B |
Sept. 6, 2020, 4:33 p.m. |
OK |
MS C++ 2017 |
TESTS |
21 |
140 |
0 |
|
|
92092672 |
kit.shiron |
B |
Sept. 6, 2020, 10:16 p.m. |
OK |
PyPy 2 |
TESTS |
31 |
233 |
8089600 |
|
|
92082055 |
Aka_coder |
B |
Sept. 6, 2020, 6:10 p.m. |
OK |
PyPy 2 |
TESTS |
31 |
249 |
8192000 |
|
|
92067206 |
lebron87 |
B |
Sept. 6, 2020, 4:12 p.m. |
OK |
PyPy 2 |
TESTS |
21 |
343 |
7782400 |
|
|
92100727 |
a0976531005 |
B |
Sept. 7, 2020, 3:28 a.m. |
OK |
PyPy 3 |
TESTS |
31 |
187 |
8601600 |
|
|
92101360 |
shhrrtnvr |
B |
Sept. 7, 2020, 3:45 a.m. |
OK |
PyPy 3 |
TESTS |
31 |
202 |
7475200 |
|
|
92083155 |
shubh_doshi |
B |
Sept. 6, 2020, 6:26 p.m. |
OK |
PyPy 3 |
TESTS |
31 |
233 |
10956800 |
|
|
92101316 |
shhrrtnvr |
B |
Sept. 7, 2020, 3:44 a.m. |
OK |
PyPy 3 |
TESTS |
31 |
248 |
10444800 |
|
|
92076977 |
dcshin |
B |
Sept. 6, 2020, 5:22 p.m. |
OK |
PyPy 3 |
TESTS |
21 |
248 |
10649600 |
|
|
92083879 |
Rudresh |
B |
Sept. 6, 2020, 6:37 p.m. |
OK |
PyPy 3 |
TESTS |
31 |
264 |
12185600 |
|
|
92085369 |
NickAs |
B |
Sept. 6, 2020, 7:01 p.m. |
OK |
PyPy 3 |
TESTS |
31 |
265 |
12185600 |
|
|
92077207 |
dopefresh |
B |
Sept. 6, 2020, 5:22 p.m. |
OK |
PyPy 3 |
TESTS |
21 |
265 |
15872000 |
|
|
92063026 |
thekushalghosh |
B |
Sept. 6, 2020, 3:57 p.m. |
OK |
PyPy 3 |
TESTS |
21 |
280 |
10649600 |
|
|
92103953 |
SPD_9X2 |
B |
Sept. 7, 2020, 4:39 a.m. |
OK |
PyPy 3 |
TESTS |
31 |
280 |
10752000 |
|
|
92082096 |
Aka_coder |
B |
Sept. 6, 2020, 6:10 p.m. |
OK |
Python 2 |
TESTS |
31 |
234 |
5632000 |
|
|
92065252 |
resita |
B |
Sept. 6, 2020, 4:05 p.m. |
OK |
Python 2 |
TESTS |
21 |
249 |
6041600 |
|
|
92101556 |
shhrrtnvr |
B |
Sept. 7, 2020, 3:49 a.m. |
OK |
Python 3 |
TESTS |
31 |
140 |
6656000 |
|
|
92065389 |
trckster |
B |
Sept. 6, 2020, 4:05 p.m. |
OK |
Python 3 |
TESTS |
21 |
171 |
7782400 |
|
|
92093997 |
ptgvo |
B |
Sept. 6, 2020, 11:20 p.m. |
OK |
Python 3 |
TESTS |
31 |
186 |
8704000 |
|
|
92070457 |
Zwgtwz |
B |
Sept. 6, 2020, 4:23 p.m. |
OK |
Python 3 |
TESTS |
21 |
186 |
8704000 |
|
|
92098068 |
eugalt |
B |
Sept. 7, 2020, 2:15 a.m. |
OK |
Python 3 |
TESTS |
31 |
187 |
7372800 |
|
|
92064755 |
eugalt |
B |
Sept. 6, 2020, 4:03 p.m. |
OK |
Python 3 |
TESTS |
21 |
187 |
7475200 |
|
|
92099765 |
301_anky |
B |
Sept. 7, 2020, 3:02 a.m. |
OK |
Python 3 |
TESTS |
31 |
187 |
8499200 |
|
|
92081969 |
shardik2001 |
B |
Sept. 6, 2020, 6:09 p.m. |
OK |
Python 3 |
TESTS |
31 |
187 |
8499200 |
|
|
92105261 |
deepcoder_B |
B |
Sept. 7, 2020, 5:04 a.m. |
OK |
Python 3 |
TESTS |
31 |
187 |
9113600 |
|
|
92102298 |
ritishkumarsingh |
B |
Sept. 7, 2020, 4:05 a.m. |
OK |
Python 3 |
TESTS |
31 |
202 |
8396800 |
|
|
92080850 |
wow_ok |
B |
Sept. 6, 2020, 5:54 p.m. |
OK |
Ruby |
TESTS |
31 |
623 |
12288000 |
|
|
92077847 |
wow_ok |
B |
Sept. 6, 2020, 5:26 p.m. |
OK |
Ruby |
TESTS |
21 |
639 |
12697600 |
|
|
92077509 |
wow_ok |
B |
Sept. 6, 2020, 5:24 p.m. |
OK |
Ruby |
TESTS |
21 |
639 |
13414400 |
|
|
92062903 |
manta1130 |
B |
Sept. 6, 2020, 3:57 p.m. |
OK |
Rust |
TESTS |
21 |
46 |
3379200 |
|
|
92095422 |
o2k |
B |
Sept. 7, 2020, 12:38 a.m. |
OK |
Rust |
TESTS |
31 |
77 |
3379200 |
|
|
92088849 |
IvanDyachenko |
B |
Sept. 6, 2020, 8:10 p.m. |
OK |
Scala |
TESTS |
31 |
561 |
5734400 |
|
|
remove filters
Back to search problems