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 are given an array of n integers a_1, a_2, ldots, a_n . The integers are either 1 or -1 . You have to perform the following operation exactly once on the array a : What is the maximum possible value of a_1 + a_2 + ldots + a_n after applying the above operation? Each test contains multiple test cases. The first line contains the number of test cases t ( 1 <= t <= 500 ). Description of the test cases follows. The first line of each test case contains a single integer n ( 2 <= n <= 10^5 ), the length of the array a . The next line contains n integers a_1, a_2, ldots, a_n ( a_i = 1 or a_i = -1 ). The sum of n over all cases doesn't exceed 10^5 . For each test case, print the maximum possible sum of the array a you can get in a separate line. In the first case, we can choose index 4 and flip the signs of a_4 and a_5 . After this operation, the sum will be -1+1+1+1+1 = 3 . We can't make the sum larger than this. In the third case, the only option is to choose the index 1 . "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
191621340 |
ahanaf101 |
A |
Feb. 1, 2023, 7:05 p.m. |
OK |
Clang++17 Diagnostics |
TESTS |
10 |
311 |
409600 |
|
|
191622970 |
NenadDapic |
A |
Feb. 1, 2023, 7:24 p.m. |
OK |
FPC |
TESTS |
10 |
31 |
102400 |
|
|
191597457 |
void_main_real |
A |
Feb. 1, 2023, 4:17 p.m. |
OK |
GNU C11 |
TESTS |
10 |
30 |
409600 |
|
|
191599179 |
zakaria17 |
A |
Feb. 1, 2023, 4:22 p.m. |
OK |
GNU C11 |
TESTS |
10 |
30 |
409600 |
|
|
191624240 |
AvikAB |
A |
Feb. 1, 2023, 7:38 p.m. |
OK |
GNU C11 |
TESTS |
10 |
31 |
409600 |
|
|
191645277 |
under_cover_ |
A |
Feb. 2, 2023, 2:07 a.m. |
OK |
GNU C11 |
TESTS |
10 |
31 |
409600 |
|
|
191648082 |
greatguys |
A |
Feb. 2, 2023, 2:53 a.m. |
OK |
GNU C11 |
TESTS |
10 |
31 |
409600 |
|
|
191655088 |
Harsha26 |
A |
Feb. 2, 2023, 4:18 a.m. |
OK |
GNU C11 |
TESTS |
10 |
31 |
409600 |
|
|
191622040 |
gauravpawar |
A |
Feb. 1, 2023, 7:13 p.m. |
OK |
GNU C11 |
TESTS |
10 |
31 |
409600 |
|
|
191615964 |
Karim_Mostafa_FOE |
A |
Feb. 1, 2023, 6:16 p.m. |
OK |
GNU C11 |
TESTS |
10 |
31 |
409600 |
|
|
191616725 |
utsav2004 |
A |
Feb. 1, 2023, 6:22 p.m. |
OK |
GNU C11 |
TESTS |
10 |
31 |
409600 |
|
|
191621920 |
sajid_knownas_hawk |
A |
Feb. 1, 2023, 7:12 p.m. |
OK |
GNU C11 |
TESTS |
10 |
31 |
409600 |
|
|
191632335 |
t1400 |
A |
Feb. 1, 2023, 9:32 p.m. |
OK |
GNU C++14 |
TESTS |
10 |
15 |
0 |
|
|
191639550 |
BzjrLuo |
A |
Feb. 2, 2023, 12:17 a.m. |
OK |
GNU C++14 |
TESTS |
10 |
15 |
409600 |
|
|
191657968 |
skyy123 |
A |
Feb. 2, 2023, 5 a.m. |
OK |
GNU C++14 |
TESTS |
11 |
15 |
409600 |
|
|
191649221 |
qijiYDC |
A |
Feb. 2, 2023, 3:09 a.m. |
OK |
GNU C++14 |
TESTS |
10 |
15 |
409600 |
|
|
191648445 |
Cu_OH_2 |
A |
Feb. 2, 2023, 2:58 a.m. |
OK |
GNU C++14 |
TESTS |
10 |
15 |
409600 |
|
|
191640105 |
DSG.yingshang |
A |
Feb. 2, 2023, 12:31 a.m. |
OK |
GNU C++14 |
TESTS |
10 |
15 |
409600 |
|
|
191639311 |
Sumit_73 |
A |
Feb. 2, 2023, 12:11 a.m. |
OK |
GNU C++14 |
TESTS |
10 |
15 |
409600 |
|
|
191636088 |
yashx314 |
A |
Feb. 1, 2023, 10:45 p.m. |
OK |
GNU C++14 |
TESTS |
10 |
15 |
819200 |
|
|
191592084 |
c-y-t |
A |
Feb. 1, 2023, 3:59 p.m. |
OK |
GNU C++14 |
TESTS |
10 |
30 |
409600 |
|
|
191658675 |
astitva27_ |
A |
Feb. 2, 2023, 5:10 a.m. |
OK |
GNU C++14 |
TESTS |
11 |
30 |
819200 |
|
|
191651975 |
Saccar |
A |
Feb. 2, 2023, 3:52 a.m. |
OK |
GNU C++17 |
TESTS |
10 |
15 |
409600 |
|
|
191611693 |
Apiram |
A |
Feb. 1, 2023, 5:46 p.m. |
OK |
GNU C++17 |
TESTS |
10 |
15 |
409600 |
|
|
191637694 |
joniaranguri |
A |
Feb. 1, 2023, 11:26 p.m. |
OK |
GNU C++17 |
TESTS |
10 |
15 |
409600 |
|
|
191638835 |
hoppas3 |
A |
Feb. 2, 2023, midnight |
OK |
GNU C++17 |
TESTS |
10 |
15 |
409600 |
|
|
191608802 |
shiv_bajpai |
A |
Feb. 1, 2023, 5:30 p.m. |
OK |
GNU C++17 |
TESTS |
10 |
15 |
819200 |
|
|
191639858 |
SADMAN |
A |
Feb. 2, 2023, 12:25 a.m. |
OK |
GNU C++17 |
TESTS |
10 |
15 |
819200 |
|
|
191629354 |
dark_knight_48 |
A |
Feb. 1, 2023, 8:46 p.m. |
OK |
GNU C++17 |
TESTS |
10 |
15 |
819200 |
|
|
191608881 |
knockcat |
A |
Feb. 1, 2023, 5:30 p.m. |
OK |
GNU C++17 |
TESTS |
10 |
15 |
819200 |
|
|
191613102 |
anupjujagar121 |
A |
Feb. 1, 2023, 5:55 p.m. |
OK |
GNU C++17 |
TESTS |
10 |
15 |
1126400 |
|
|
191649902 |
Beginner343 |
A |
Feb. 2, 2023, 3:21 a.m. |
OK |
GNU C++17 |
TESTS |
10 |
15 |
1638400 |
|
|
191631192 |
_akasi |
A |
Feb. 1, 2023, 9:14 p.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
15 |
409600 |
|
|
191609022 |
virt_contest_taker |
A |
Feb. 1, 2023, 5:31 p.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
15 |
409600 |
|
|
191653263 |
yl_neo |
A |
Feb. 2, 2023, 4:12 a.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
15 |
409600 |
|
|
191646295 |
EotUL8d7 |
A |
Feb. 2, 2023, 2:23 a.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
15 |
409600 |
|
|
191643044 |
camc |
A |
Feb. 2, 2023, 1:29 a.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
15 |
409600 |
|
|
191642406 |
fakhoury |
A |
Feb. 2, 2023, 1:17 a.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
15 |
409600 |
|
|
191615363 |
MD_Kazi_Muhaimin_Mahi |
A |
Feb. 1, 2023, 6:11 p.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
15 |
819200 |
|
|
191592187 |
pranavb.02 |
A |
Feb. 1, 2023, 4 p.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
15 |
819200 |
|
|
191595777 |
Keshab1113 |
A |
Feb. 1, 2023, 4:11 p.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
15 |
819200 |
|
|
191614253 |
exceed_06 |
A |
Feb. 1, 2023, 6:03 p.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
15 |
819200 |
|
|
191622688 |
jerwu |
A |
Feb. 1, 2023, 7:20 p.m. |
OK |
GNU C++20 (64) |
TESTS |
10 |
15 |
0 |
|
|
191641690 |
OkClinty |
A |
Feb. 2, 2023, 1:03 a.m. |
OK |
GNU C++20 (64) |
TESTS |
10 |
15 |
0 |
|
|
191593302 |
0xAB.rar |
A |
Feb. 1, 2023, 4:03 p.m. |
OK |
GNU C++20 (64) |
TESTS |
10 |
15 |
0 |
|
|
191643611 |
Churufuz |
A |
Feb. 2, 2023, 1:40 a.m. |
OK |
GNU C++20 (64) |
TESTS |
10 |
15 |
0 |
|
|
191640597 |
dudegladiator |
A |
Feb. 2, 2023, 12:41 a.m. |
OK |
GNU C++20 (64) |
TESTS |
10 |
15 |
0 |
|
|
191636475 |
_SADIEM_ |
A |
Feb. 1, 2023, 10:54 p.m. |
OK |
GNU C++20 (64) |
TESTS |
10 |
15 |
0 |
|
|
191599430 |
Navi_Profi |
A |
Feb. 1, 2023, 4:23 p.m. |
OK |
GNU C++20 (64) |
TESTS |
10 |
15 |
307200 |
|
|
191657571 |
Shady_Mo |
A |
Feb. 2, 2023, 4:55 a.m. |
OK |
GNU C++20 (64) |
TESTS |
11 |
15 |
409600 |
|
|
191657733 |
Rinors |
A |
Feb. 2, 2023, 4:57 a.m. |
OK |
GNU C++20 (64) |
TESTS |
11 |
15 |
409600 |
|
|
191659997 |
Fang_Yi |
A |
Feb. 2, 2023, 5:28 a.m. |
OK |
GNU C++20 (64) |
TESTS |
11 |
15 |
409600 |
|
|
191661828 |
_samit_ |
A |
Feb. 2, 2023, 5:51 a.m. |
OK |
Go |
TESTS |
11 |
46 |
1433600 |
|
|
191612279 |
as9274 |
A |
Feb. 1, 2023, 5:50 p.m. |
OK |
Java 11 |
TESTS |
10 |
171 |
0 |
|
|
191653461 |
Jackyjuman |
A |
Feb. 2, 2023, 4:15 a.m. |
OK |
Java 11 |
TESTS |
10 |
187 |
0 |
|
|
191641454 |
wantu |
A |
Feb. 2, 2023, 12:58 a.m. |
OK |
Java 11 |
TESTS |
10 |
187 |
0 |
|
|
191623017 |
pakkapapad |
A |
Feb. 1, 2023, 7:24 p.m. |
OK |
Java 11 |
TESTS |
10 |
187 |
0 |
|
|
191611289 |
ABINAYA.S_CSE |
A |
Feb. 1, 2023, 5:43 p.m. |
OK |
Java 11 |
TESTS |
10 |
202 |
0 |
|
|
191661189 |
NithinBharathi |
A |
Feb. 2, 2023, 5:43 a.m. |
OK |
Java 11 |
TESTS |
11 |
202 |
0 |
|
|
191645998 |
aswad2 |
A |
Feb. 2, 2023, 2:18 a.m. |
OK |
Java 11 |
TESTS |
10 |
202 |
0 |
|
|
191615357 |
Ankitsks |
A |
Feb. 1, 2023, 6:11 p.m. |
OK |
Java 11 |
TESTS |
10 |
202 |
0 |
|
|
191609622 |
prakhars_18 |
A |
Feb. 1, 2023, 5:34 p.m. |
OK |
Java 11 |
TESTS |
10 |
202 |
0 |
|
|
191637967 |
knovise |
A |
Feb. 1, 2023, 11:32 p.m. |
OK |
Java 11 |
TESTS |
10 |
202 |
40345600 |
|
|
191649053 |
daftdove |
A |
Feb. 2, 2023, 3:07 a.m. |
OK |
Java 17 |
TESTS |
10 |
187 |
716800 |
|
|
191626393 |
ahmed.elbakly |
A |
Feb. 1, 2023, 8:05 p.m. |
OK |
Java 17 |
TESTS |
10 |
202 |
102400 |
|
|
191603009 |
itsMr1 |
A |
Feb. 1, 2023, 4:33 p.m. |
OK |
Java 17 |
TESTS |
10 |
217 |
307200 |
|
|
191633424 |
arpurush |
A |
Feb. 1, 2023, 9:51 p.m. |
OK |
Java 17 |
TESTS |
10 |
218 |
409600 |
|
|
191616397 |
not_just_rr |
A |
Feb. 1, 2023, 6:19 p.m. |
OK |
Java 17 |
TESTS |
10 |
218 |
614400 |
|
|
191616519 |
swatishivam23 |
A |
Feb. 1, 2023, 6:20 p.m. |
OK |
Java 17 |
TESTS |
10 |
264 |
5324800 |
|
|
191626710 |
Adar8604 |
A |
Feb. 1, 2023, 8:10 p.m. |
OK |
Java 17 |
TESTS |
10 |
296 |
819200 |
|
|
191614249 |
akshayraut8080 |
A |
Feb. 1, 2023, 6:03 p.m. |
OK |
Java 17 |
TESTS |
10 |
296 |
819200 |
|
|
191615889 |
Devansh-gaur-1611 |
A |
Feb. 1, 2023, 6:15 p.m. |
OK |
Java 17 |
TESTS |
10 |
296 |
921600 |
|
|
191599612 |
papa_kipari_13 |
A |
Feb. 1, 2023, 4:23 p.m. |
OK |
Java 17 |
TESTS |
10 |
311 |
102400 |
|
|
191609246 |
Koka |
A |
Feb. 1, 2023, 5:32 p.m. |
OK |
Java 8 |
TESTS |
10 |
108 |
0 |
|
|
191592160 |
n0obie |
A |
Feb. 1, 2023, 4 p.m. |
OK |
Java 8 |
TESTS |
10 |
108 |
0 |
|
|
191624226 |
lpychemistry |
A |
Feb. 1, 2023, 7:38 p.m. |
OK |
Java 8 |
TESTS |
10 |
124 |
0 |
|
|
191611176 |
alikhan_emes |
A |
Feb. 1, 2023, 5:43 p.m. |
OK |
Java 8 |
TESTS |
10 |
124 |
0 |
|
|
191594584 |
ShivanRawat19 |
A |
Feb. 1, 2023, 4:07 p.m. |
OK |
Java 8 |
TESTS |
10 |
140 |
0 |
|
|
191607973 |
rohan_12 |
A |
Feb. 1, 2023, 5:25 p.m. |
OK |
Java 8 |
TESTS |
10 |
155 |
0 |
|
|
191655142 |
amit_roy |
A |
Feb. 2, 2023, 4:19 a.m. |
OK |
Java 8 |
TESTS |
10 |
202 |
0 |
|
|
191651033 |
Jered_ |
A |
Feb. 2, 2023, 3:38 a.m. |
OK |
Java 8 |
TESTS |
10 |
202 |
0 |
|
|
191629529 |
Ishan11Singh |
A |
Feb. 1, 2023, 8:49 p.m. |
OK |
Java 8 |
TESTS |
10 |
202 |
0 |
|
|
191620757 |
Priyanka1551 |
A |
Feb. 1, 2023, 6:59 p.m. |
OK |
Java 8 |
TESTS |
10 |
202 |
0 |
|
|
191623785 |
Krantzy |
A |
Feb. 1, 2023, 7:34 p.m. |
OK |
Kotlin 1.7 |
TESTS |
10 |
452 |
33996800 |
|
|
191594144 |
evja.z |
A |
Feb. 1, 2023, 4:06 p.m. |
OK |
MS C++ 2017 |
TESTS |
10 |
46 |
409600 |
|
|
191640709 |
CuandHNO3 |
A |
Feb. 2, 2023, 12:43 a.m. |
OK |
MS C++ 2017 |
TESTS |
10 |
62 |
409600 |
|
|
191615518 |
abdullah1108 |
A |
Feb. 1, 2023, 6:12 p.m. |
OK |
MS C++ 2017 |
TESTS |
10 |
62 |
409600 |
|
|
191615319 |
153floppa |
A |
Feb. 1, 2023, 6:11 p.m. |
OK |
MS C++ 2017 |
TESTS |
10 |
62 |
1433600 |
|
|
191592523 |
KarkiAayush01 |
A |
Feb. 1, 2023, 4:01 p.m. |
OK |
MS C++ 2017 |
TESTS |
10 |
62 |
1433600 |
|
|
191652428 |
GANDOR |
A |
Feb. 2, 2023, 3:59 a.m. |
OK |
MS C++ 2017 |
TESTS |
10 |
78 |
409600 |
|
|
191617015 |
shobonvip |
A |
Feb. 1, 2023, 6:24 p.m. |
OK |
PyPy 3 |
TESTS |
10 |
140 |
6041600 |
|
|
191634511 |
imnowhere |
A |
Feb. 1, 2023, 10:12 p.m. |
OK |
PyPy 3 |
TESTS |
10 |
140 |
6656000 |
|
|
191623632 |
DeadlyFe |
A |
Feb. 1, 2023, 7:31 p.m. |
OK |
PyPy 3 |
TESTS |
10 |
155 |
6758400 |
|
|
191650739 |
bpdolson |
A |
Feb. 2, 2023, 3:33 a.m. |
OK |
PyPy 3 |
TESTS |
10 |
155 |
7475200 |
|
|
191632213 |
Noureldin |
A |
Feb. 1, 2023, 9:30 p.m. |
OK |
PyPy 3 |
TESTS |
10 |
155 |
8499200 |
|
|
191661178 |
rup.yes |
A |
Feb. 2, 2023, 5:43 a.m. |
OK |
PyPy 3 |
TESTS |
11 |
156 |
6963200 |
|
|
191603116 |
yash7890 |
A |
Feb. 1, 2023, 4:34 p.m. |
OK |
PyPy 3 |
TESTS |
10 |
170 |
3276800 |
|
|
191629053 |
zx4r |
A |
Feb. 1, 2023, 8:41 p.m. |
OK |
PyPy 3 |
TESTS |
10 |
171 |
6758400 |
|
|
191639398 |
crapcode |
A |
Feb. 2, 2023, 12:13 a.m. |
OK |
PyPy 3-64 |
TESTS |
10 |
62 |
13209600 |
|
|
191623063 |
rmr |
A |
Feb. 1, 2023, 7:25 p.m. |
OK |
PyPy 3-64 |
TESTS |
10 |
77 |
9830400 |
|
|
191643305 |
hkwu6013 |
A |
Feb. 2, 2023, 1:35 a.m. |
OK |
PyPy 3-64 |
TESTS |
10 |
77 |
12185600 |
|
|
191614134 |
gardengnome |
A |
Feb. 1, 2023, 6:02 p.m. |
OK |
PyPy 3-64 |
TESTS |
10 |
77 |
13004800 |
|
|
191648220 |
zaphar |
A |
Feb. 2, 2023, 2:55 a.m. |
OK |
PyPy 3-64 |
TESTS |
10 |
77 |
13312000 |
|
|
191647560 |
Youarenotgood |
A |
Feb. 2, 2023, 2:45 a.m. |
OK |
PyPy 3-64 |
TESTS |
10 |
77 |
13516800 |
|
|
191625352 |
Alex239 |
A |
Feb. 1, 2023, 7:52 p.m. |
OK |
PyPy 3-64 |
TESTS |
10 |
93 |
8704000 |
|
|
191598149 |
2momo2 |
A |
Feb. 1, 2023, 4:19 p.m. |
OK |
PyPy 3-64 |
TESTS |
10 |
93 |
9011200 |
|
|
191621100 |
sangeeta |
A |
Feb. 1, 2023, 7:02 p.m. |
OK |
PyPy 3-64 |
TESTS |
10 |
93 |
12902400 |
|
|
191613303 |
gesuta |
A |
Feb. 1, 2023, 5:57 p.m. |
OK |
PyPy 3-64 |
TESTS |
10 |
93 |
13004800 |
|
|
191652272 |
harishk12345 |
A |
Feb. 2, 2023, 3:57 a.m. |
OK |
Python 3 |
TESTS |
10 |
61 |
3481600 |
|
|
191610216 |
R_PRANAV_GUHAN |
A |
Feb. 1, 2023, 5:37 p.m. |
OK |
Python 3 |
TESTS |
10 |
61 |
3891200 |
|
|
191608469 |
eugalt |
A |
Feb. 1, 2023, 5:28 p.m. |
OK |
Python 3 |
TESTS |
10 |
62 |
3276800 |
|
|
191612246 |
Kladrr |
A |
Feb. 1, 2023, 5:50 p.m. |
OK |
Python 3 |
TESTS |
10 |
62 |
3379200 |
|
|
191658110 |
prabhatchanchal |
A |
Feb. 2, 2023, 5:02 a.m. |
OK |
Python 3 |
TESTS |
11 |
62 |
3481600 |
|
|
191655669 |
shefat2002 |
A |
Feb. 2, 2023, 4:27 a.m. |
OK |
Python 3 |
TESTS |
10 |
62 |
3481600 |
|
|
191654951 |
Teja_Potturi |
A |
Feb. 2, 2023, 4:16 a.m. |
OK |
Python 3 |
TESTS |
10 |
62 |
3481600 |
|
|
191650955 |
muhammadsharif |
A |
Feb. 2, 2023, 3:37 a.m. |
OK |
Python 3 |
TESTS |
10 |
62 |
3481600 |
|
|
191627726 |
Fazly-Fardin |
A |
Feb. 1, 2023, 8:23 p.m. |
OK |
Python 3 |
TESTS |
10 |
62 |
3481600 |
|
|
191618973 |
KiaRez |
A |
Feb. 1, 2023, 6:41 p.m. |
OK |
Python 3 |
TESTS |
10 |
62 |
3686400 |
|
|
191598595 |
manvithchandra |
A |
Feb. 1, 2023, 4:20 p.m. |
OK |
Ruby 3 |
TESTS |
10 |
295 |
6246400 |
|
|
191631399 |
dbalchev |
A |
Feb. 1, 2023, 9:17 p.m. |
OK |
Rust 2021 |
TESTS |
10 |
30 |
6656000 |
|
|
191626294 |
liut |
A |
Feb. 1, 2023, 8:04 p.m. |
OK |
Rust 2021 |
TESTS |
10 |
31 |
409600 |
|
|
remove filters
Back to search problems