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 a binary string s of length n . Let's define d_i as the number whose decimal representation is s_i s_{i+1} (possibly, with a leading zero). We define f(s) to be the sum of all the valid d_i . In other words, f(s) = sum limits_{i=1}^{n-1} d_i . For example, for the string s = 1011 : In one operation you can swap any two adjacent elements of the string. Find the minimum value of f(s) that can be achieved if at most k operations are allowed. Each test contains multiple test cases. The first line contains the number of test cases t ( 1 <= t <= 10^5 ). Description of the test cases follows. First line of each test case contains two integers n and k ( 2 <= n <= 10^5 , 0 <= k <= 10^9 ) -- the length of the string and the maximum number of operations allowed. The second line of each test case contains the binary string s of length n , consisting of only zeros and ones. It is also given that sum of n over all the test cases doesn't exceed 10^5 . For each test case, print the minimum value of f(s) you can obtain with at most k operations. "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
159209964 |
QuacNoobLoL |
C |
June 2, 2022, 3:30 a.m. |
OK |
C# 10 |
TESTS |
37 |
124 |
2560000 |
|
|
159165118 |
Afzal_Hossan |
C |
June 1, 2022, 1:24 p.m. |
OK |
GNU C11 |
TESTS |
37 |
61 |
102400 |
|
|
159147705 |
1435730 |
C |
June 1, 2022, 10:04 a.m. |
OK |
GNU C11 |
TESTS |
37 |
61 |
102400 |
|
|
159206829 |
hotpotcondiment |
C |
June 2, 2022, 1:56 a.m. |
OK |
GNU C++14 |
TESTS |
37 |
15 |
102400 |
|
|
159158492 |
WhyWhy |
C |
June 1, 2022, 12:08 p.m. |
OK |
GNU C++14 |
TESTS |
37 |
15 |
102400 |
|
|
159156896 |
snnu_lgw |
C |
June 1, 2022, 11:49 a.m. |
OK |
GNU C++14 |
TESTS |
37 |
15 |
102400 |
|
|
159156118 |
gzchenben |
C |
June 1, 2022, 11:40 a.m. |
OK |
GNU C++14 |
TESTS |
37 |
15 |
102400 |
|
|
159152932 |
nnnnnxxxxx |
C |
June 1, 2022, 11:02 a.m. |
OK |
GNU C++14 |
TESTS |
37 |
15 |
102400 |
|
|
159137104 |
nipungoyal03 |
C |
June 1, 2022, 8:07 a.m. |
OK |
GNU C++14 |
TESTS |
37 |
15 |
102400 |
|
|
159121834 |
594188 |
C |
June 1, 2022, 4:54 a.m. |
OK |
GNU C++14 |
TESTS |
37 |
15 |
102400 |
|
|
159211263 |
Canace_HKF |
C |
June 2, 2022, 4:06 a.m. |
OK |
GNU C++14 |
TESTS |
37 |
15 |
102400 |
|
|
159209287 |
lingying |
C |
June 2, 2022, 3:11 a.m. |
OK |
GNU C++14 |
TESTS |
37 |
15 |
102400 |
|
|
159206572 |
AC__hunter |
C |
June 2, 2022, 1:47 a.m. |
OK |
GNU C++14 |
TESTS |
37 |
15 |
204800 |
|
|
159164340 |
3396724494 |
C |
June 1, 2022, 1:16 p.m. |
OK |
GNU C++17 |
TESTS |
37 |
15 |
102400 |
|
|
159158291 |
yuanzhoulvpi |
C |
June 1, 2022, 12:06 p.m. |
OK |
GNU C++17 |
TESTS |
37 |
15 |
102400 |
|
|
159137127 |
KAUSTUBH152003 |
C |
June 1, 2022, 8:07 a.m. |
OK |
GNU C++17 |
TESTS |
37 |
15 |
102400 |
|
|
159122471 |
ischyros |
C |
June 1, 2022, 5:04 a.m. |
OK |
GNU C++17 |
TESTS |
37 |
15 |
102400 |
|
|
159168167 |
Tian_chen |
C |
June 1, 2022, 1:58 p.m. |
OK |
GNU C++17 |
TESTS |
37 |
15 |
102400 |
|
|
159194934 |
Gold_Dragon |
C |
June 1, 2022, 7:34 p.m. |
OK |
GNU C++17 |
TESTS |
37 |
15 |
102400 |
|
|
159127203 |
krit3379 |
C |
June 1, 2022, 6:08 a.m. |
OK |
GNU C++17 |
TESTS |
37 |
15 |
204800 |
|
|
159124696 |
palsatyam877 |
C |
June 1, 2022, 5:36 a.m. |
OK |
GNU C++17 |
TESTS |
37 |
15 |
204800 |
|
|
159159664 |
WingWingSQ |
C |
June 1, 2022, 12:22 p.m. |
OK |
GNU C++17 |
TESTS |
37 |
15 |
204800 |
|
|
159158693 |
Amr.7 |
C |
June 1, 2022, 12:11 p.m. |
OK |
GNU C++17 |
TESTS |
37 |
15 |
204800 |
|
|
159162827 |
Andreasyan |
C |
June 1, 2022, 12:58 p.m. |
OK |
GNU C++17 (64) |
TESTS |
37 |
15 |
102400 |
|
|
159133352 |
OTTFF |
C |
June 1, 2022, 7:21 a.m. |
OK |
GNU C++17 (64) |
TESTS |
37 |
15 |
102400 |
|
|
159138038 |
thusloop |
C |
June 1, 2022, 8:19 a.m. |
OK |
GNU C++17 (64) |
TESTS |
37 |
15 |
204800 |
|
|
159177023 |
FAILURE. |
C |
June 1, 2022, 3:42 p.m. |
OK |
GNU C++17 (64) |
TESTS |
37 |
15 |
307200 |
|
|
159174685 |
wcwu |
C |
June 1, 2022, 3:13 p.m. |
OK |
GNU C++17 (64) |
TESTS |
37 |
15 |
307200 |
|
|
159173749 |
opPO |
C |
June 1, 2022, 3:01 p.m. |
OK |
GNU C++17 (64) |
TESTS |
37 |
15 |
307200 |
|
|
159213705 |
Lycoriss |
C |
June 2, 2022, 4:57 a.m. |
OK |
GNU C++17 (64) |
TESTS |
37 |
15 |
307200 |
|
|
159186919 |
Ma7moud7amdy |
C |
June 1, 2022, 5:38 p.m. |
OK |
GNU C++17 (64) |
TESTS |
37 |
15 |
307200 |
|
|
159187639 |
RenegadeKamikaze |
C |
June 1, 2022, 5:47 p.m. |
OK |
GNU C++17 (64) |
TESTS |
37 |
15 |
307200 |
|
|
159191541 |
Dreviolos |
C |
June 1, 2022, 6:37 p.m. |
OK |
GNU C++17 (64) |
TESTS |
37 |
15 |
307200 |
|
|
159132803 |
give5 |
C |
June 1, 2022, 7:15 a.m. |
OK |
GNU C++20 (64) |
TESTS |
37 |
15 |
0 |
|
|
159149707 |
segmentfault EDIEEee |
C |
June 1, 2022, 10:26 a.m. |
OK |
GNU C++20 (64) |
TESTS |
37 |
15 |
102400 |
|
|
159126134 |
w-- |
C |
June 1, 2022, 5:55 a.m. |
OK |
GNU C++20 (64) |
TESTS |
37 |
15 |
102400 |
|
|
159188790 |
rgmhv08 |
C |
June 1, 2022, 6:01 p.m. |
OK |
GNU C++20 (64) |
TESTS |
37 |
15 |
204800 |
|
|
159206369 |
stricks |
C |
June 2, 2022, 1:39 a.m. |
OK |
GNU C++20 (64) |
TESTS |
37 |
15 |
204800 |
|
|
159196436 |
saksham_999 |
C |
June 1, 2022, 8:03 p.m. |
OK |
GNU C++20 (64) |
TESTS |
37 |
15 |
204800 |
|
|
159187683 |
Dev_Goel |
C |
June 1, 2022, 5:47 p.m. |
OK |
GNU C++20 (64) |
TESTS |
37 |
15 |
204800 |
|
|
159174821 |
LeamuR |
C |
June 1, 2022, 3:15 p.m. |
OK |
GNU C++20 (64) |
TESTS |
37 |
15 |
204800 |
|
|
159173539 |
kuonji_ |
C |
June 1, 2022, 2:58 p.m. |
OK |
GNU C++20 (64) |
TESTS |
37 |
15 |
204800 |
|
|
159171076 |
TheDeadSoul |
C |
June 1, 2022, 2:29 p.m. |
OK |
GNU C++20 (64) |
TESTS |
37 |
15 |
204800 |
|
|
159154482 |
yudi23 |
C |
June 1, 2022, 11:21 a.m. |
OK |
Java 11 |
TESTS |
37 |
171 |
0 |
|
|
159128639 |
__Serendipity |
C |
June 1, 2022, 6:25 a.m. |
OK |
Java 11 |
TESTS |
37 |
171 |
0 |
|
|
159154291 |
yudi23 |
C |
June 1, 2022, 11:19 a.m. |
OK |
Java 11 |
TESTS |
37 |
186 |
0 |
|
|
159143255 |
rachitagrawal1011 |
C |
June 1, 2022, 9:16 a.m. |
OK |
Java 11 |
TESTS |
37 |
186 |
0 |
|
|
159124553 |
NO__OB |
C |
June 1, 2022, 5:34 a.m. |
OK |
Java 11 |
TESTS |
37 |
187 |
0 |
|
|
159155719 |
Arjun-Ichiban |
C |
June 1, 2022, 11:35 a.m. |
OK |
Java 11 |
TESTS |
37 |
187 |
0 |
|
|
159125405 |
Stirboy |
C |
June 1, 2022, 5:45 a.m. |
OK |
Java 11 |
TESTS |
37 |
187 |
0 |
|
|
159203397 |
Plums |
C |
June 1, 2022, 11:31 p.m. |
OK |
Java 11 |
TESTS |
37 |
202 |
0 |
|
|
159180306 |
nbhakar |
C |
June 1, 2022, 4:19 p.m. |
OK |
Java 11 |
TESTS |
37 |
202 |
0 |
|
|
159144096 |
_shinCHAN_ |
C |
June 1, 2022, 9:25 a.m. |
OK |
Java 11 |
TESTS |
37 |
202 |
0 |
|
|
159160811 |
alibaba |
C |
June 1, 2022, 12:35 p.m. |
OK |
Java 8 |
TESTS |
37 |
93 |
0 |
|
|
159166212 |
param_2001 |
C |
June 1, 2022, 1:36 p.m. |
OK |
Java 8 |
TESTS |
37 |
108 |
0 |
|
|
159162492 |
BhargavModha |
C |
June 1, 2022, 12:55 p.m. |
OK |
Java 8 |
TESTS |
37 |
108 |
0 |
|
|
159133813 |
TopSafder |
C |
June 1, 2022, 7:27 a.m. |
OK |
Java 8 |
TESTS |
37 |
108 |
0 |
|
|
159179734 |
green_619 |
C |
June 1, 2022, 4:12 p.m. |
OK |
Java 8 |
TESTS |
37 |
109 |
0 |
|
|
159157688 |
ak_ankit |
C |
June 1, 2022, 11:58 a.m. |
OK |
Java 8 |
TESTS |
37 |
109 |
0 |
|
|
159153586 |
adityasin9h |
C |
June 1, 2022, 11:10 a.m. |
OK |
Java 8 |
TESTS |
37 |
109 |
0 |
|
|
159148585 |
UniversalAdmin |
C |
June 1, 2022, 10:14 a.m. |
OK |
Java 8 |
TESTS |
37 |
109 |
0 |
|
|
159121717 |
govindrajput |
C |
June 1, 2022, 4:52 a.m. |
OK |
Java 8 |
TESTS |
37 |
109 |
0 |
|
|
159162515 |
slow.coder |
C |
June 1, 2022, 12:55 p.m. |
OK |
Java 8 |
TESTS |
37 |
124 |
0 |
|
|
159141662 |
serg_alb |
C |
June 1, 2022, 8:59 a.m. |
OK |
Kotlin 1.5 |
TESTS |
37 |
421 |
9728000 |
|
|
159196603 |
manish_morjal |
C |
June 1, 2022, 8:06 p.m. |
OK |
MS C++ 2017 |
TESTS |
37 |
46 |
307200 |
|
|
159175005 |
1_shivam |
C |
June 1, 2022, 3:18 p.m. |
OK |
MS C++ 2017 |
TESTS |
37 |
46 |
307200 |
|
|
159137397 |
bill_0vd |
C |
June 1, 2022, 8:10 a.m. |
OK |
MS C++ 2017 |
TESTS |
37 |
61 |
307200 |
|
|
159171889 |
toxahak |
C |
June 1, 2022, 2:38 p.m. |
OK |
Node.js |
TESTS |
37 |
108 |
6041600 |
|
|
159168994 |
YMSeah |
C |
June 1, 2022, 2:07 p.m. |
OK |
PyPy 3 |
TESTS |
37 |
124 |
5836800 |
|
|
159189176 |
YashNandwana |
C |
June 1, 2022, 6:06 p.m. |
OK |
PyPy 3 |
TESTS |
37 |
186 |
7270400 |
|
|
159127452 |
practise_iiitb |
C |
June 1, 2022, 6:11 a.m. |
OK |
PyPy 3 |
TESTS |
37 |
186 |
9625600 |
|
|
159202773 |
samuelbrashears |
C |
June 1, 2022, 11:03 p.m. |
OK |
PyPy 3 |
TESTS |
37 |
187 |
9420800 |
|
|
159124422 |
Kishen19 |
C |
June 1, 2022, 5:32 a.m. |
OK |
PyPy 3 |
TESTS |
37 |
187 |
9420800 |
|
|
159133936 |
ludwings0330 |
C |
June 1, 2022, 7:28 a.m. |
OK |
PyPy 3 |
TESTS |
37 |
218 |
7987200 |
|
|
159124359 |
mmooyyii |
C |
June 1, 2022, 5:31 a.m. |
OK |
PyPy 3 |
TESTS |
37 |
233 |
9830400 |
|
|
159133251 |
KanishkGoel |
C |
June 1, 2022, 7:20 a.m. |
OK |
PyPy 3 |
TESTS |
37 |
389 |
9523200 |
|
|
159197352 |
V.S.R |
C |
June 1, 2022, 8:22 p.m. |
OK |
PyPy 3 |
TESTS |
37 |
405 |
9420800 |
|
|
159168670 |
ASTRODUDE_09 |
C |
June 1, 2022, 2:03 p.m. |
OK |
PyPy 3 |
TESTS |
37 |
421 |
9830400 |
|
|
159164103 |
tushar26427 |
C |
June 1, 2022, 1:13 p.m. |
OK |
PyPy 3-64 |
TESTS |
37 |
109 |
9523200 |
|
|
159200392 |
RANK1ZEN |
C |
June 1, 2022, 9:41 p.m. |
OK |
PyPy 3-64 |
TESTS |
37 |
124 |
7782400 |
|
|
159203454 |
Juanm1 |
C |
June 1, 2022, 11:34 p.m. |
OK |
PyPy 3-64 |
TESTS |
37 |
124 |
9625600 |
|
|
159135503 |
s_prateek26 |
C |
June 1, 2022, 7:48 a.m. |
OK |
PyPy 3-64 |
TESTS |
37 |
140 |
7475200 |
|
|
159185851 |
iron_nicko |
C |
June 1, 2022, 5:25 p.m. |
OK |
PyPy 3-64 |
TESTS |
37 |
155 |
9523200 |
|
|
159187982 |
toxic_tandem |
C |
June 1, 2022, 5:51 p.m. |
OK |
PyPy 3-64 |
TESTS |
37 |
171 |
9523200 |
|
|
159187840 |
MashaM |
C |
June 1, 2022, 5:49 p.m. |
OK |
PyPy 3-64 |
TESTS |
37 |
171 |
9523200 |
|
|
159201798 |
jerwu |
C |
June 1, 2022, 10:25 p.m. |
OK |
PyPy 3-64 |
TESTS |
37 |
171 |
10444800 |
|
|
159133664 |
Anti-Neutrino |
C |
June 1, 2022, 7:25 a.m. |
OK |
PyPy 3-64 |
TESTS |
37 |
202 |
10035200 |
|
|
159129554 |
majay1638 |
C |
June 1, 2022, 6:35 a.m. |
OK |
PyPy 3-64 |
TESTS |
37 |
233 |
10137600 |
|
|
159171418 |
KeiTsukishima |
C |
June 1, 2022, 2:33 p.m. |
OK |
Python 3 |
TESTS |
37 |
77 |
307200 |
|
|
159166356 |
2021_01472 |
C |
June 1, 2022, 1:37 p.m. |
OK |
Python 3 |
TESTS |
37 |
109 |
716800 |
|
|
159131201 |
vrajpatel001 |
C |
June 1, 2022, 6:55 a.m. |
OK |
Python 3 |
TESTS |
37 |
139 |
204800 |
|
|
159184435 |
Ayush_ag |
C |
June 1, 2022, 5:08 p.m. |
OK |
Python 3 |
TESTS |
37 |
155 |
307200 |
|
|
159177499 |
Ak_basniwal |
C |
June 1, 2022, 3:47 p.m. |
OK |
Python 3 |
TESTS |
37 |
155 |
307200 |
|
|
159156053 |
rajesh_455 |
C |
June 1, 2022, 11:39 a.m. |
OK |
Python 3 |
TESTS |
37 |
155 |
307200 |
|
|
159129882 |
bishtman12 |
C |
June 1, 2022, 6:39 a.m. |
OK |
Python 3 |
TESTS |
37 |
155 |
512000 |
|
|
159169242 |
2021eeb1193 |
C |
June 1, 2022, 2:10 p.m. |
OK |
Python 3 |
TESTS |
37 |
171 |
307200 |
|
|
159134459 |
harshal_509 |
C |
June 1, 2022, 7:35 a.m. |
OK |
Python 3 |
TESTS |
37 |
171 |
716800 |
|
|
159157913 |
Tiru_t |
C |
June 1, 2022, 12:02 p.m. |
OK |
Python 3 |
TESTS |
37 |
186 |
512000 |
|
|
remove filters
Back to search problems