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"Polycarp's workday lasts exactly n minutes. He loves chocolate bars and can eat one bar in one minute. Today Polycarp has k bars at the beginning of the workday. In some minutes of the workday Polycarp has important things to do and in such minutes he is not able to eat a chocolate bar. In other minutes he can either eat or not eat one chocolate bar. It is guaranteed, that in the first and in the last minutes of the workday Polycarp has no important things to do and he will always eat bars in this minutes to gladden himself at the begining and at the end of the workday. Also it is guaranteed, that k is strictly greater than 1 . Your task is to determine such an order of eating chocolate bars that the maximum break time between eating bars is as minimum as possible. Consider that Polycarp eats a bar in the minute x and the next bar in the minute y ( x < y ). Then the break time is equal to y - x - 1 minutes. It is not necessary for Polycarp to eat all bars he has. The first line contains two integers n and k ( 2 <= n <= 200 ,000 , 2 <= k <= n ) -- the length of the workday in minutes and the number of chocolate bars, which Polycarp has in the beginning of the workday. The second line contains the string with length n consisting of zeros and ones. If the i -th symbol in the string equals to zero, Polycarp has no important things to do in the minute i and he can eat a chocolate bar. In the other case, Polycarp is busy in the minute i and can not eat a chocolate bar. It is guaranteed, that the first and the last characters of the string are equal to zero, and Polycarp always eats chocolate bars in these minutes. Print the minimum possible break in minutes between eating chocolate bars. In the first example Polycarp can not eat the chocolate bar in the second minute, so the time of the break equals to one minute. In the second example Polycarp will eat bars in the minu"... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
26153716 |
Vasily_PML30 LizaVasilenko |
L |
April 5, 2017, 5:11 p.m. |
OK |
D |
TESTS |
81 |
46 |
7168000 |
|
2200 |
26152712 |
StarScreamOwl ednotdead |
L |
April 5, 2017, 4:55 p.m. |
OK |
Delphi |
TESTS |
81 |
93 |
4198400 |
|
2200 |
26151905 |
victor_kzk MaDCaT |
L |
April 5, 2017, 4:44 p.m. |
OK |
FPC |
TESTS |
81 |
15 |
3788800 |
|
2200 |
36221822 |
Samsara_Karma applese |
L |
March 12, 2018, 11:29 a.m. |
OK |
FPC |
TESTS |
81 |
31 |
3993600 |
|
2200 |
26154122 |
Grzegorz jaguar1996 |
L |
April 5, 2017, 5:16 p.m. |
OK |
GNU C |
TESTS |
81 |
15 |
2048000 |
|
2200 |
26152724 |
Me-and-Myself zetilovn |
L |
April 5, 2017, 4:55 p.m. |
OK |
GNU C |
TESTS |
81 |
15 |
2048000 |
|
2200 |
26231578 |
_ShadowSong |
L |
April 9, 2017, 7:11 a.m. |
OK |
GNU C |
TESTS |
81 |
15 |
2150400 |
|
2200 |
26151164 |
Tiko sparik |
L |
April 5, 2017, 4:35 p.m. |
OK |
GNU C |
TESTS |
81 |
31 |
2867200 |
|
2200 |
26153037 |
Eran Javanochka |
L |
April 5, 2017, 5 p.m. |
OK |
GNU C |
TESTS |
81 |
46 |
2048000 |
|
2200 |
26152774 |
shirokami ColdSu |
L |
April 5, 2017, 4:56 p.m. |
OK |
GNU C++ |
TESTS |
81 |
15 |
2252800 |
|
2200 |
26154756 |
taxicoo Alex.lap |
L |
April 5, 2017, 5:26 p.m. |
OK |
GNU C11 |
TESTS |
81 |
15 |
2150400 |
|
2200 |
26154620 |
kodek bitcom |
L |
April 5, 2017, 5:24 p.m. |
OK |
GNU C11 |
TESTS |
81 |
15 |
2150400 |
|
2200 |
59541549 |
rainboy |
L |
Aug. 26, 2019, 7:09 p.m. |
OK |
GNU C11 |
TESTS |
81 |
31 |
204800 |
|
2200 |
26150730 |
Birjik Meirambek |
L |
April 5, 2017, 4:29 p.m. |
OK |
GNU C11 |
TESTS |
81 |
31 |
2867200 |
|
2200 |
26153095 |
konvpalto Comrad_of_Stalin |
L |
April 5, 2017, 5:01 p.m. |
OK |
GNU C11 |
TESTS |
81 |
46 |
2662400 |
|
2200 |
26176927 |
artem28 |
L |
April 6, 2017, 6:10 p.m. |
OK |
GNU C11 |
TESTS |
81 |
46 |
6860800 |
|
2200 |
26177029 |
kuko- |
L |
April 6, 2017, 6:16 p.m. |
OK |
GNU C++11 |
TESTS |
81 |
15 |
2457600 |
|
2200 |
26200087 |
aleex |
L |
April 7, 2017, 5:24 p.m. |
OK |
GNU C++11 |
TESTS |
81 |
15 |
2560000 |
|
2200 |
26184390 |
Toxel |
L |
April 7, 2017, 5:17 a.m. |
OK |
GNU C++11 |
TESTS |
81 |
15 |
3891200 |
|
2200 |
61746213 |
Madeeyuth |
L |
Oct. 3, 2019, 12:34 a.m. |
OK |
GNU C++11 |
TESTS |
81 |
31 |
819200 |
|
2200 |
26154912 |
Jeffrey |
L |
April 5, 2017, 5:28 p.m. |
OK |
GNU C++11 |
TESTS |
81 |
31 |
2662400 |
|
2200 |
57770173 |
py_ultron |
L |
July 25, 2019, 11:51 p.m. |
OK |
GNU C++11 |
TESTS |
81 |
46 |
1126400 |
|
2200 |
57875374 |
lopare |
L |
July 28, 2019, 4:55 a.m. |
OK |
GNU C++11 |
TESTS |
81 |
46 |
1126400 |
|
2200 |
26154673 |
alexander89116 LLIAMA3OB |
L |
April 5, 2017, 5:24 p.m. |
OK |
GNU C++11 |
TESTS |
81 |
46 |
2560000 |
|
2200 |
26154705 |
FireZi Impy |
L |
April 5, 2017, 5:25 p.m. |
OK |
GNU C++11 |
TESTS |
81 |
46 |
3379200 |
|
2200 |
26155425 |
amirrr lightning |
L |
April 5, 2017, 5:33 p.m. |
OK |
GNU C++11 |
TESTS |
81 |
46 |
3379200 |
|
2200 |
26346965 |
wp32pw |
L |
April 13, 2017, 8:23 p.m. |
OK |
GNU C++14 |
TESTS |
81 |
15 |
2150400 |
|
2200 |
26151734 |
gars Provet |
L |
April 5, 2017, 4:42 p.m. |
OK |
GNU C++14 |
TESTS |
81 |
15 |
2457600 |
|
2200 |
26155231 |
rickya maxxaon |
L |
April 5, 2017, 5:32 p.m. |
OK |
GNU C++14 |
TESTS |
81 |
15 |
2764800 |
|
2200 |
26151199 |
KingArthur |
L |
April 5, 2017, 4:35 p.m. |
OK |
GNU C++14 |
TESTS |
81 |
15 |
3481600 |
|
2200 |
26154857 |
l_Love_KFC Jupiter |
L |
April 5, 2017, 5:27 p.m. |
OK |
GNU C++14 |
TESTS |
81 |
15 |
4403200 |
|
2200 |
26153133 |
Reventon YaKon4ick |
L |
April 5, 2017, 5:01 p.m. |
OK |
GNU C++14 |
TESTS |
81 |
30 |
3686400 |
|
2200 |
54861770 |
NiroBC |
L |
May 31, 2019, 2:47 a.m. |
OK |
GNU C++14 |
TESTS |
81 |
31 |
204800 |
|
2200 |
51889541 |
rav.gupta |
L |
March 27, 2019, 8:24 a.m. |
OK |
GNU C++14 |
TESTS |
81 |
31 |
2048000 |
|
2200 |
40982227 |
ReaLNero1 |
L |
July 30, 2018, 6:20 p.m. |
OK |
GNU C++14 |
TESTS |
81 |
31 |
2150400 |
|
2200 |
38477146 |
shaochengxi |
L |
May 21, 2018, 8:02 a.m. |
OK |
GNU C++14 |
TESTS |
81 |
46 |
1126400 |
|
2200 |
69100062 |
Phortox |
L |
Jan. 19, 2020, 1:37 p.m. |
OK |
GNU C++17 |
TESTS |
81 |
31 |
1331200 |
|
2200 |
61749643 |
Madeeyuth |
L |
Oct. 3, 2019, 2:36 a.m. |
OK |
GNU C++17 |
TESTS |
81 |
46 |
3993600 |
|
2200 |
59542800 |
laspinko |
L |
Aug. 26, 2019, 7:46 p.m. |
OK |
GNU C++17 |
TESTS |
81 |
62 |
512000 |
|
2200 |
26154057 |
VernitaGreen svxf |
L |
April 5, 2017, 5:15 p.m. |
OK |
Go |
TESTS |
81 |
436 |
24166400 |
|
2200 |
60351619 |
Petro1488 |
L |
Sept. 10, 2019, 2:31 p.m. |
OK |
Java 8 |
TESTS |
81 |
124 |
0 |
|
2200 |
59541548 |
Dukkha |
L |
Aug. 26, 2019, 7:09 p.m. |
OK |
Java 8 |
TESTS |
81 |
155 |
0 |
|
2200 |
26154669 |
FIvO |
L |
April 5, 2017, 5:24 p.m. |
OK |
Java 8 |
TESTS |
81 |
171 |
20889600 |
|
2200 |
26151793 |
mihaiI Djok216 |
L |
April 5, 2017, 4:42 p.m. |
OK |
Java 8 |
TESTS |
81 |
171 |
20992000 |
|
2200 |
26150695 |
Gewery wafemand |
L |
April 5, 2017, 4:29 p.m. |
OK |
Java 8 |
TESTS |
81 |
187 |
20889600 |
|
2200 |
26514515 |
krijgertje |
L |
April 20, 2017, 11:38 a.m. |
OK |
JavaScript |
TESTS |
81 |
61 |
6246400 |
|
2200 |
26151212 |
chdn AndrewB330 |
L |
April 5, 2017, 4:35 p.m. |
OK |
Mono C# |
TESTS |
81 |
62 |
9830400 |
|
2200 |
26153998 |
NikitaMikhaylov expl0si0nn |
L |
April 5, 2017, 5:14 p.m. |
OK |
Mono C# |
TESTS |
81 |
62 |
11980800 |
|
2200 |
26151731 |
svetlana_lana GoldenMan |
L |
April 5, 2017, 4:42 p.m. |
OK |
Mono C# |
TESTS |
81 |
62 |
13824000 |
|
2200 |
26155499 |
equocredite Xpech |
L |
April 5, 2017, 5:34 p.m. |
OK |
MS C# |
TESTS |
81 |
62 |
13824000 |
|
2200 |
26155346 |
emelyan AdMiRaLL |
L |
April 5, 2017, 5:33 p.m. |
OK |
MS C# |
TESTS |
81 |
93 |
13004800 |
|
2200 |
26153467 |
irka1804 YtkaBTapkax |
L |
April 5, 2017, 5:07 p.m. |
OK |
MS C++ |
TESTS |
81 |
30 |
3481600 |
|
2200 |
26154027 |
Kniaz Schemtschik |
L |
April 5, 2017, 5:15 p.m. |
OK |
MS C++ |
TESTS |
81 |
31 |
2764800 |
|
2200 |
26165944 |
ViruZ |
L |
April 6, 2017, 9:33 a.m. |
OK |
PHP |
TESTS |
81 |
405 |
6041600 |
|
2200 |
26155064 |
Stilusoid kisa_is_bdsm |
L |
April 5, 2017, 5:30 p.m. |
OK |
PyPy 3 |
TESTS |
81 |
171 |
25702400 |
|
2200 |
26202505 |
yelghareeb |
L |
April 7, 2017, 7:45 p.m. |
OK |
Python 2 |
TESTS |
81 |
701 |
5120000 |
|
2200 |
26178362 |
Zhigan |
L |
April 6, 2017, 7:36 p.m. |
OK |
Python 2 |
TESTS |
81 |
1106 |
8192000 |
|
2200 |
26154989 |
snek_Case sincerity |
L |
April 5, 2017, 5:29 p.m. |
OK |
Python 3 |
TESTS |
81 |
1154 |
6144000 |
|
2200 |
26498926 |
Captain_Canada |
L |
April 19, 2017, 3:16 p.m. |
OK |
Python 3 |
TESTS |
81 |
1746 |
11776000 |
|
2200 |
remove filters
Back to search problems