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'A binary string is a string consisting only of the characters 0 and 1. You are given a binary string s . For some non-empty substring ^ dagger t of string s containing x characters 0 and y characters 1, define its cost as: Given a binary string s of length n , find the maximum cost across all its non-empty substrings. ^ dagger A string a is a substring of a string b if a can be obtained from b by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end. Each test consists of multiple test cases. The first line contains a single integer t ( 1 <= q t <= q 10^5 ) -- the number of test cases. The description of test cases follows. The first line of each test case contains a single integer n ( 1 <= n <= 2 cdot 10^5 ) -- the length of the string s . The second line of each test case contains a binary string s of length n . It is guaranteed that the sum of n over all test cases does not exceed 2 cdot 10^5 . For each test case, print a single integer -- the maximum cost across all substrings. In the first test case, we can take a substring 111 . It contains 3 characters 1 and 0 characters 0. So a = 3 , b = 0 and its cost is 3^2 = 9 . In the second test case, we can take the whole string. It contains 4 characters 1 and 3 characters 0. So a = 4 , b = 3 and its cost is 4 cdot 3 = 12 . In the third test case, we can can take a substring 1111 and its cost is 4^2 = 16 . In the fourth test case, we can take the whole string and cost is 4 cdot 3 = 12 . In the fifth test case, we can take a substring 000 and its cost is 3 cdot 3 = 9 . In the sixth test case, we can only take the substring 0 and its cost is 1 cdot 1 = 1 . '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
179632364 |
MiKate |
B |
Nov. 6, 2022, 4:54 p.m. |
OK |
C# 8 |
TESTS |
9 |
873 |
31027200 |
|
|
179615826 |
duymao |
B |
Nov. 6, 2022, 3:58 p.m. |
OK |
GNU C11 |
TESTS |
9 |
390 |
204800 |
|
|
179831544 |
CaveNightingale |
B |
Nov. 7, 2022, 12:35 a.m. |
OK |
GNU C11 |
TESTS |
13 |
405 |
0 |
|
|
179632701 |
Miraemon |
B |
Nov. 6, 2022, 4:55 p.m. |
OK |
GNU C11 |
TESTS |
9 |
405 |
204800 |
|
|
179685233 |
SP2003 |
B |
Nov. 6, 2022, 5:29 p.m. |
OK |
GNU C11 |
TESTS |
13 |
420 |
204800 |
|
|
179839857 |
Silencer76 |
B |
Nov. 7, 2022, 2:16 a.m. |
OK |
GNU C11 |
TESTS |
13 |
421 |
204800 |
|
|
179614981 |
SAFIN07 |
B |
Nov. 6, 2022, 3:55 p.m. |
OK |
GNU C11 |
TESTS |
9 |
421 |
204800 |
|
|
179615630 |
iffatul_anon |
B |
Nov. 6, 2022, 3:57 p.m. |
OK |
GNU C11 |
TESTS |
9 |
421 |
204800 |
|
|
179615121 |
DariaFung |
B |
Nov. 6, 2022, 3:55 p.m. |
OK |
GNU C11 |
TESTS |
9 |
421 |
819200 |
|
|
179831628 |
CaveNightingale |
B |
Nov. 7, 2022, 12:37 a.m. |
OK |
GNU C11 |
TESTS |
13 |
436 |
0 |
|
|
179614694 |
mrgaolll |
B |
Nov. 6, 2022, 3:54 p.m. |
OK |
GNU C11 |
TESTS |
9 |
436 |
204800 |
|
|
179613808 |
arm.gp23 |
B |
Nov. 6, 2022, 3:50 p.m. |
OK |
GNU C++14 |
TESTS |
9 |
30 |
512000 |
|
|
179817776 |
Hussein_M.Elmorsy |
B |
Nov. 6, 2022, 7:34 p.m. |
OK |
GNU C++14 |
TESTS |
13 |
30 |
512000 |
|
|
179624910 |
item2023 |
B |
Nov. 6, 2022, 4:35 p.m. |
OK |
GNU C++14 |
TESTS |
9 |
30 |
1843200 |
|
|
179618440 |
gousefw0 |
B |
Nov. 6, 2022, 4:09 p.m. |
OK |
GNU C++14 |
TESTS |
9 |
30 |
2560000 |
|
|
179837147 |
william556 |
B |
Nov. 7, 2022, 1:15 a.m. |
OK |
GNU C++14 |
TESTS |
13 |
31 |
204800 |
|
|
179844569 |
QY2002 |
B |
Nov. 7, 2022, 3:44 a.m. |
OK |
GNU C++14 |
TESTS |
13 |
31 |
204800 |
|
|
179840912 |
GMXH |
B |
Nov. 7, 2022, 2:36 a.m. |
OK |
GNU C++14 |
TESTS |
13 |
31 |
204800 |
|
|
179830904 |
L7-56 |
B |
Nov. 7, 2022, 12:17 a.m. |
OK |
GNU C++14 |
TESTS |
13 |
31 |
204800 |
|
|
179829883 |
_Index_ |
B |
Nov. 6, 2022, 11:41 p.m. |
OK |
GNU C++14 |
TESTS |
13 |
31 |
204800 |
|
|
179869641 |
vic-cgh |
B |
Nov. 7, 2022, 4:12 a.m. |
OK |
GNU C++14 |
TESTS |
13 |
31 |
409600 |
|
|
179615791 |
Subodh12 |
B |
Nov. 6, 2022, 3:58 p.m. |
OK |
GNU C++17 |
TESTS |
9 |
15 |
512000 |
|
|
179839766 |
kk19212 |
B |
Nov. 7, 2022, 2:14 a.m. |
OK |
GNU C++17 |
TESTS |
13 |
15 |
1228800 |
|
|
179844701 |
mr-strange |
B |
Nov. 7, 2022, 3:46 a.m. |
OK |
GNU C++17 |
TESTS |
13 |
30 |
512000 |
|
|
179887174 |
itsmefaisal |
B |
Nov. 7, 2022, 5:24 a.m. |
OK |
GNU C++17 |
TESTS |
13 |
30 |
512000 |
|
|
179761346 |
snavneet561 |
B |
Nov. 6, 2022, 6:09 p.m. |
OK |
GNU C++17 |
TESTS |
13 |
30 |
512000 |
|
|
179762119 |
K0DEL |
B |
Nov. 6, 2022, 6:18 p.m. |
OK |
GNU C++17 |
TESTS |
13 |
30 |
512000 |
|
|
179817650 |
Optimus1234 |
B |
Nov. 6, 2022, 7:32 p.m. |
OK |
GNU C++17 |
TESTS |
13 |
30 |
512000 |
|
|
179618205 |
Tushar499 |
B |
Nov. 6, 2022, 4:08 p.m. |
OK |
GNU C++17 |
TESTS |
9 |
30 |
512000 |
|
|
179684178 |
GenVinCoder |
B |
Nov. 6, 2022, 5:23 p.m. |
OK |
GNU C++17 |
TESTS |
9 |
30 |
512000 |
|
|
179685976 |
medeshi.kristian |
B |
Nov. 6, 2022, 5:35 p.m. |
OK |
GNU C++17 |
TESTS |
13 |
30 |
512000 |
|
|
179839738 |
zhrrrr |
B |
Nov. 7, 2022, 2:13 a.m. |
OK |
GNU C++17 (64) |
TESTS |
13 |
15 |
512000 |
|
|
179621278 |
HHerski |
B |
Nov. 6, 2022, 4:21 p.m. |
OK |
GNU C++17 (64) |
TESTS |
9 |
15 |
512000 |
|
|
179618853 |
youesfhassan256. |
B |
Nov. 6, 2022, 4:10 p.m. |
OK |
GNU C++17 (64) |
TESTS |
9 |
15 |
512000 |
|
|
179842031 |
pursuit_of_happiness |
B |
Nov. 7, 2022, 2:55 a.m. |
OK |
GNU C++17 (64) |
TESTS |
13 |
15 |
512000 |
|
|
179685429 |
Huntik_03 |
B |
Nov. 6, 2022, 5:31 p.m. |
OK |
GNU C++17 (64) |
TESTS |
13 |
15 |
512000 |
|
|
179832147 |
linxd |
B |
Nov. 7, 2022, 12:52 a.m. |
OK |
GNU C++17 (64) |
TESTS |
13 |
15 |
1331200 |
|
|
179685501 |
leo25 |
B |
Nov. 6, 2022, 5:31 p.m. |
OK |
GNU C++17 (64) |
TESTS |
13 |
30 |
0 |
|
|
179819919 |
mesbah19 |
B |
Nov. 6, 2022, 8:04 p.m. |
OK |
GNU C++17 (64) |
TESTS |
13 |
30 |
512000 |
|
|
179824632 |
uBpc |
B |
Nov. 6, 2022, 9:24 p.m. |
OK |
GNU C++17 (64) |
TESTS |
13 |
30 |
512000 |
|
|
179821779 |
ravirkumar2422 |
B |
Nov. 6, 2022, 8:34 p.m. |
OK |
GNU C++17 (64) |
TESTS |
13 |
30 |
512000 |
|
|
179823532 |
Jon |
B |
Nov. 6, 2022, 9:03 p.m. |
OK |
GNU C++20 (64) |
TESTS |
13 |
15 |
0 |
|
|
179830948 |
N_z__ |
B |
Nov. 7, 2022, 12:18 a.m. |
OK |
GNU C++20 (64) |
TESTS |
13 |
15 |
102400 |
|
|
179842125 |
SamuelAbatneh |
B |
Nov. 7, 2022, 2:57 a.m. |
OK |
GNU C++20 (64) |
TESTS |
13 |
15 |
512000 |
|
|
179901107 |
Prag2003 |
B |
Nov. 7, 2022, 5:59 a.m. |
OK |
GNU C++20 (64) |
TESTS |
13 |
15 |
512000 |
|
|
179899981 |
bin_s |
B |
Nov. 7, 2022, 5:42 a.m. |
OK |
GNU C++20 (64) |
TESTS |
13 |
15 |
512000 |
|
|
179887393 |
Bob15324 |
B |
Nov. 7, 2022, 5:28 a.m. |
OK |
GNU C++20 (64) |
TESTS |
13 |
15 |
512000 |
|
|
179872725 |
Saarthak_10 |
B |
Nov. 7, 2022, 4:33 a.m. |
OK |
GNU C++20 (64) |
TESTS |
13 |
15 |
512000 |
|
|
179851259 |
rishit_30g |
B |
Nov. 7, 2022, 3:58 a.m. |
OK |
GNU C++20 (64) |
TESTS |
13 |
15 |
512000 |
|
|
179841941 |
SamuelAbatneh |
B |
Nov. 7, 2022, 2:54 a.m. |
OK |
GNU C++20 (64) |
TESTS |
13 |
15 |
512000 |
|
|
179832527 |
001_LTC |
B |
Nov. 7, 2022, 1:02 a.m. |
OK |
GNU C++20 (64) |
TESTS |
13 |
15 |
512000 |
|
|
179632426 |
sotsir |
B |
Nov. 6, 2022, 4:54 p.m. |
OK |
Go |
TESTS |
9 |
342 |
4300800 |
|
|
179832349 |
rajneesh.osho |
B |
Nov. 7, 2022, 12:57 a.m. |
OK |
Java 11 |
TESTS |
13 |
171 |
0 |
|
|
179819294 |
cpp10 |
B |
Nov. 6, 2022, 7:55 p.m. |
OK |
Java 11 |
TESTS |
13 |
187 |
0 |
|
|
179685852 |
__Serendipity |
B |
Nov. 6, 2022, 5:34 p.m. |
OK |
Java 11 |
TESTS |
13 |
187 |
0 |
|
|
179821761 |
Yousef_Badr |
B |
Nov. 6, 2022, 8:34 p.m. |
OK |
Java 11 |
TESTS |
13 |
202 |
0 |
|
|
179684716 |
naman5811 |
B |
Nov. 6, 2022, 5:26 p.m. |
OK |
Java 11 |
TESTS |
9 |
202 |
0 |
|
|
179619425 |
sduMamutbekov |
B |
Nov. 6, 2022, 4:13 p.m. |
OK |
Java 11 |
TESTS |
9 |
218 |
0 |
|
|
179901289 |
sf14t |
B |
Nov. 7, 2022, 6:02 a.m. |
OK |
Java 11 |
TESTS |
13 |
218 |
0 |
|
|
179807265 |
handle007 |
B |
Nov. 6, 2022, 6:37 p.m. |
OK |
Java 11 |
TESTS |
13 |
218 |
0 |
|
|
179628631 |
alimingoi |
B |
Nov. 6, 2022, 4:49 p.m. |
OK |
Java 11 |
TESTS |
9 |
265 |
3788800 |
|
|
179622023 |
nastjiya |
B |
Nov. 6, 2022, 4:24 p.m. |
OK |
Java 11 |
TESTS |
9 |
280 |
0 |
|
|
179815149 |
less_ordinary |
B |
Nov. 6, 2022, 7 p.m. |
OK |
Java 17 |
TESTS |
13 |
233 |
307200 |
|
|
179686531 |
Thejas_n |
B |
Nov. 6, 2022, 5:37 p.m. |
OK |
Java 17 |
TESTS |
13 |
249 |
614400 |
|
|
179614218 |
Mihir05 |
B |
Nov. 6, 2022, 3:52 p.m. |
OK |
Java 17 |
TESTS |
9 |
451 |
1024000 |
|
|
179616972 |
ishita1802 |
B |
Nov. 6, 2022, 4:02 p.m. |
OK |
Java 17 |
TESTS |
9 |
655 |
1126400 |
|
|
179870293 |
Ankur_Tiwari__ |
B |
Nov. 7, 2022, 4:27 a.m. |
OK |
Java 17 |
TESTS |
13 |
686 |
4710400 |
|
|
179829893 |
Jay_17 |
B |
Nov. 6, 2022, 11:41 p.m. |
OK |
Java 17 |
TESTS |
13 |
701 |
614400 |
|
|
179736180 |
Ahmed_Ashraf112 |
B |
Nov. 6, 2022, 5:54 p.m. |
OK |
Java 17 |
TESTS |
13 |
701 |
614400 |
|
|
179617979 |
gurjeet_7000 |
B |
Nov. 6, 2022, 4:07 p.m. |
OK |
Java 17 |
TESTS |
9 |
701 |
716800 |
|
|
179621414 |
coderev_12 |
B |
Nov. 6, 2022, 4:21 p.m. |
OK |
Java 17 |
TESTS |
9 |
701 |
819200 |
|
|
179622035 |
NS_69b |
B |
Nov. 6, 2022, 4:24 p.m. |
OK |
Java 17 |
TESTS |
9 |
717 |
204800 |
|
|
179813860 |
gagan_6730 |
B |
Nov. 6, 2022, 6:45 p.m. |
OK |
Java 8 |
TESTS |
13 |
108 |
0 |
|
|
179807301 |
Koka |
B |
Nov. 6, 2022, 6:38 p.m. |
OK |
Java 8 |
TESTS |
13 |
109 |
0 |
|
|
179819053 |
mohamedhassan_c |
B |
Nov. 6, 2022, 7:52 p.m. |
OK |
Java 8 |
TESTS |
13 |
124 |
0 |
|
|
179742457 |
jkslyk |
B |
Nov. 6, 2022, 5:57 p.m. |
OK |
Java 8 |
TESTS |
13 |
124 |
0 |
|
|
179742365 |
jkslyk |
B |
Nov. 6, 2022, 5:56 p.m. |
OK |
Java 8 |
TESTS |
13 |
124 |
0 |
|
|
179841316 |
SoKee_USTC |
B |
Nov. 7, 2022, 2:43 a.m. |
OK |
Java 8 |
TESTS |
13 |
140 |
0 |
|
|
179816682 |
rish1896 |
B |
Nov. 6, 2022, 7:19 p.m. |
OK |
Java 8 |
TESTS |
13 |
140 |
0 |
|
|
179684371 |
ikillmyself |
B |
Nov. 6, 2022, 5:24 p.m. |
OK |
Java 8 |
TESTS |
9 |
140 |
0 |
|
|
179621167 |
SoKee_USTC |
B |
Nov. 6, 2022, 4:20 p.m. |
OK |
Java 8 |
TESTS |
9 |
171 |
0 |
|
|
179684415 |
Juhaied_nabid |
B |
Nov. 6, 2022, 5:24 p.m. |
OK |
Java 8 |
TESTS |
9 |
280 |
0 |
|
|
179621293 |
hossen53 |
B |
Nov. 6, 2022, 4:21 p.m. |
OK |
JavaScript |
TESTS |
9 |
467 |
1331200 |
|
|
179622870 |
artsemy |
B |
Nov. 6, 2022, 4:28 p.m. |
OK |
JavaScript |
TESTS |
9 |
655 |
9523200 |
|
|
179684630 |
Sgyun |
B |
Nov. 6, 2022, 5:25 p.m. |
OK |
Kotlin 1.6 |
TESTS |
9 |
841 |
5222400 |
|
|
179813626 |
catforce |
B |
Nov. 6, 2022, 6:42 p.m. |
OK |
Kotlin 1.6 |
TESTS |
13 |
873 |
0 |
|
|
179832014 |
Ichronus |
B |
Nov. 7, 2022, 12:47 a.m. |
OK |
MS C++ 2017 |
TESTS |
13 |
436 |
614400 |
|
|
179900846 |
LiuZhaocheng |
B |
Nov. 7, 2022, 5:56 a.m. |
OK |
MS C++ 2017 |
TESTS |
13 |
451 |
2252800 |
|
|
179625984 |
OtttType2 |
B |
Nov. 6, 2022, 4:39 p.m. |
OK |
MS C++ 2017 |
TESTS |
9 |
452 |
204800 |
|
|
179631216 |
k_bhayan |
B |
Nov. 6, 2022, 4:50 p.m. |
OK |
MS C++ 2017 |
TESTS |
9 |
452 |
409600 |
|
|
179620997 |
Mosey |
B |
Nov. 6, 2022, 4:19 p.m. |
OK |
MS C++ 2017 |
TESTS |
9 |
468 |
1843200 |
|
|
179622275 |
martinc1194 |
B |
Nov. 6, 2022, 4:25 p.m. |
OK |
MS C++ 2017 |
TESTS |
9 |
483 |
614400 |
|
|
179761644 |
Yash_Nandwana |
B |
Nov. 6, 2022, 6:12 p.m. |
OK |
PyPy 3 |
TESTS |
13 |
265 |
9523200 |
|
|
179729593 |
arthursdays |
B |
Nov. 6, 2022, 5:48 p.m. |
OK |
PyPy 3 |
TESTS |
13 |
295 |
9830400 |
|
|
179627784 |
ZzaZi |
B |
Nov. 6, 2022, 4:45 p.m. |
OK |
PyPy 3 |
TESTS |
9 |
483 |
10035200 |
|
|
179755201 |
unknown-user |
B |
Nov. 6, 2022, 6:06 p.m. |
OK |
PyPy 3-64 |
TESTS |
13 |
93 |
9318400 |
|
|
179851353 |
PraveenDhinwa |
B |
Nov. 7, 2022, 3:59 a.m. |
OK |
PyPy 3-64 |
TESTS |
13 |
124 |
9318400 |
|
|
179829665 |
Trem0r |
B |
Nov. 6, 2022, 11:33 p.m. |
OK |
PyPy 3-64 |
TESTS |
13 |
140 |
10342400 |
|
|
179748449 |
Fishion |
B |
Nov. 6, 2022, 5:58 p.m. |
OK |
PyPy 3-64 |
TESTS |
13 |
155 |
9011200 |
|
|
179814905 |
zouyu9631 |
B |
Nov. 6, 2022, 6:57 p.m. |
OK |
PyPy 3-64 |
TESTS |
13 |
155 |
16588800 |
|
|
179829337 |
Trem0r |
B |
Nov. 6, 2022, 11:21 p.m. |
OK |
PyPy 3-64 |
TESTS |
13 |
170 |
11878400 |
|
|
179851007 |
harshk_52 |
B |
Nov. 7, 2022, 3:53 a.m. |
OK |
PyPy 3-64 |
TESTS |
13 |
171 |
10342400 |
|
|
179829836 |
VladTs |
B |
Nov. 6, 2022, 11:39 p.m. |
OK |
PyPy 3-64 |
TESTS |
13 |
171 |
11059200 |
|
|
179774270 |
gesuta |
B |
Nov. 6, 2022, 6:21 p.m. |
OK |
PyPy 3-64 |
TESTS |
13 |
171 |
11571200 |
|
|
179830199 |
VladTs |
B |
Nov. 6, 2022, 11:54 p.m. |
OK |
PyPy 3-64 |
TESTS |
13 |
186 |
11264000 |
|
|
179840242 |
xph_4n |
B |
Nov. 7, 2022, 2:24 a.m. |
OK |
Python 2 |
TESTS |
13 |
343 |
3686400 |
|
|
179761150 |
unknown-user |
B |
Nov. 6, 2022, 6:07 p.m. |
OK |
Python 3 |
TESTS |
13 |
248 |
6963200 |
|
|
179627394 |
k1zlt_z |
B |
Nov. 6, 2022, 4:43 p.m. |
OK |
Python 3 |
TESTS |
9 |
343 |
4300800 |
|
|
179761890 |
gck_16 |
B |
Nov. 6, 2022, 6:15 p.m. |
OK |
Python 3 |
TESTS |
13 |
389 |
4300800 |
|
|
179887150 |
unfettered_one |
B |
Nov. 7, 2022, 5:24 a.m. |
OK |
Python 3 |
TESTS |
13 |
436 |
4710400 |
|
|
179873141 |
clownhacker |
B |
Nov. 7, 2022, 4:41 a.m. |
OK |
Python 3 |
TESTS |
13 |
436 |
4710400 |
|
|
179838307 |
Mueez_Aizdi |
B |
Nov. 7, 2022, 1:43 a.m. |
OK |
Python 3 |
TESTS |
13 |
451 |
716800 |
|
|
179838699 |
Mian_Talha_g |
B |
Nov. 7, 2022, 1:51 a.m. |
OK |
Python 3 |
TESTS |
13 |
468 |
716800 |
|
|
179843440 |
1101_ |
B |
Nov. 7, 2022, 3:22 a.m. |
OK |
Python 3 |
TESTS |
13 |
483 |
4812800 |
|
|
179620426 |
The.Flash.Man |
B |
Nov. 6, 2022, 4:17 p.m. |
OK |
Python 3 |
TESTS |
9 |
483 |
8192000 |
|
|
179620351 |
ALovelyGirl |
B |
Nov. 6, 2022, 4:17 p.m. |
OK |
Python 3 |
TESTS |
9 |
483 |
8192000 |
|
|
179873608 |
1101_ |
B |
Nov. 7, 2022, 4:50 a.m. |
OK |
Rust 2021 |
TESTS |
13 |
31 |
5836800 |
|
|
179873936 |
1101_ |
B |
Nov. 7, 2022, 4:56 a.m. |
OK |
Rust 2021 |
TESTS |
13 |
46 |
1945600 |
|
|
remove filters
Back to search problems