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'There is a ribbon divided into n cells, numbered from 1 to n from left to right. Each cell either contains a chip or is free. You can perform the following operation any number of times (possibly zero): choose a chip and move it to the closest free cell to the left. You can choose any chip that you want, provided that there is at least one free cell to the left of it. When you move the chip, the cell where it was before the operation becomes free. Your goal is to move the chips in such a way that they form a single block, without any free cells between them. What is the minimum number of operations you have to perform? The first line contains one integer t ( 1 <= t <= 1000 ) -- the number of test cases. Each test case consists of two lines: Additional constraint on the input: in each test case, at least one cell contains a chip. For each test case, print one integer -- the minimum number of operations you have to perform so that all chips form a single block without any free cells between them. In the first example, you can perform the operation on the chip in the 7 -th cell. The closest free cell to the left is the 5 -th cell, so it moves there. After that, all chips form a single block. In the second example, all chips are already in a single block. Same for the third example. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
248000731 |
john6 |
A |
Feb. 23, 2024, 6:39 p.m. |
OK |
Clang++17 Diagnostics |
TESTS |
3 |
186 |
1024000 |
|
|
247982309 |
sastastudent |
A |
Feb. 23, 2024, 4:47 p.m. |
OK |
Clang++20 Diagnostics |
TESTS |
3 |
155 |
0 |
|
|
247982386 |
xiongyx2022 |
A |
Feb. 23, 2024, 4:48 p.m. |
OK |
Clang++20 Diagnostics |
TESTS |
3 |
155 |
0 |
|
|
247995926 |
IIITstudent |
A |
Feb. 23, 2024, 6:07 p.m. |
OK |
Clang++20 Diagnostics |
TESTS |
3 |
155 |
0 |
|
|
247998487 |
Aytan88 |
A |
Feb. 23, 2024, 6:24 p.m. |
OK |
Clang++20 Diagnostics |
TESTS |
3 |
155 |
0 |
|
|
247979007 |
kausar77 |
A |
Feb. 23, 2024, 4:36 p.m. |
OK |
Clang++20 Diagnostics |
TESTS |
3 |
155 |
1024000 |
|
|
248016665 |
prometheus18 |
A |
Feb. 23, 2024, 8:58 p.m. |
OK |
GNU C11 |
TESTS |
3 |
15 |
0 |
|
|
247979953 |
renish_dsouza |
A |
Feb. 23, 2024, 4:39 p.m. |
OK |
GNU C11 |
TESTS |
3 |
15 |
0 |
|
|
247993486 |
DEVARSH_007 |
A |
Feb. 23, 2024, 5:51 p.m. |
OK |
GNU C11 |
TESTS |
3 |
15 |
0 |
|
|
248035712 |
Shah_Makhdum_Sharif |
A |
Feb. 24, 2024, 2:57 a.m. |
OK |
GNU C11 |
TESTS |
3 |
15 |
0 |
|
|
248033688 |
elmiluqman |
A |
Feb. 24, 2024, 2:16 a.m. |
OK |
GNU C11 |
TESTS |
3 |
15 |
307200 |
|
|
248005971 |
ashab.tanim |
A |
Feb. 23, 2024, 7:18 p.m. |
OK |
GNU C11 |
TESTS |
3 |
15 |
307200 |
|
|
247983285 |
sastastudent |
A |
Feb. 23, 2024, 4:51 p.m. |
OK |
GNU C11 |
TESTS |
3 |
15 |
307200 |
|
|
247992931 |
coder_arindam |
A |
Feb. 23, 2024, 5:47 p.m. |
OK |
GNU C11 |
TESTS |
3 |
30 |
307200 |
|
|
248032975 |
nakshatra4585 |
A |
Feb. 24, 2024, 2:01 a.m. |
OK |
GNU C11 |
TESTS |
3 |
31 |
307200 |
|
|
248044547 |
AJAY14 |
A |
Feb. 24, 2024, 5:04 a.m. |
OK |
GNU C11 |
TESTS |
3 |
31 |
307200 |
|
|
248028099 |
Prady |
A |
Feb. 24, 2024, 12:06 a.m. |
OK |
GNU C++17 |
TESTS |
3 |
0 |
0 |
|
|
248049304 |
yashs2004 |
A |
Feb. 24, 2024, 5:53 a.m. |
OK |
GNU C++17 |
TESTS |
3 |
0 |
0 |
|
|
248049205 |
sudhirMTS |
A |
Feb. 24, 2024, 5:52 a.m. |
OK |
GNU C++17 |
TESTS |
3 |
0 |
0 |
|
|
248048610 |
Banis |
A |
Feb. 24, 2024, 5:47 a.m. |
OK |
GNU C++17 |
TESTS |
3 |
0 |
0 |
|
|
248043927 |
manish9660 |
A |
Feb. 24, 2024, 4:57 a.m. |
OK |
GNU C++17 |
TESTS |
3 |
0 |
0 |
|
|
248031810 |
mortyseb |
A |
Feb. 24, 2024, 1:35 a.m. |
OK |
GNU C++17 |
TESTS |
3 |
0 |
0 |
|
|
248029167 |
xhgua |
A |
Feb. 24, 2024, 12:31 a.m. |
OK |
GNU C++17 |
TESTS |
3 |
0 |
0 |
|
|
248018293 |
mohammad_1 |
A |
Feb. 23, 2024, 9:17 p.m. |
OK |
GNU C++17 |
TESTS |
3 |
0 |
0 |
|
|
248014387 |
antariksh_kashyap |
A |
Feb. 23, 2024, 8:33 p.m. |
OK |
GNU C++17 |
TESTS |
3 |
0 |
0 |
|
|
248008870 |
hacizadal |
A |
Feb. 23, 2024, 7:42 p.m. |
OK |
GNU C++17 |
TESTS |
3 |
0 |
0 |
|
|
248027805 |
forest1145141919810 |
A |
Feb. 23, 2024, 11:59 p.m. |
OK |
GNU C++17 (64) |
TESTS |
3 |
0 |
0 |
|
|
248028484 |
dcchendada |
A |
Feb. 24, 2024, 12:16 a.m. |
OK |
GNU C++17 (64) |
TESTS |
3 |
0 |
0 |
|
|
248029032 |
Ether13 |
A |
Feb. 24, 2024, 12:28 a.m. |
OK |
GNU C++17 (64) |
TESTS |
3 |
0 |
0 |
|
|
248030554 |
Ntd123 |
A |
Feb. 24, 2024, 1:04 a.m. |
OK |
GNU C++17 (64) |
TESTS |
3 |
0 |
0 |
|
|
248032607 |
chappy1 |
A |
Feb. 24, 2024, 1:53 a.m. |
OK |
GNU C++17 (64) |
TESTS |
3 |
0 |
0 |
|
|
248033317 |
DanRan02 |
A |
Feb. 24, 2024, 2:08 a.m. |
OK |
GNU C++17 (64) |
TESTS |
3 |
0 |
0 |
|
|
248033893 |
zhujio |
A |
Feb. 24, 2024, 2:21 a.m. |
OK |
GNU C++17 (64) |
TESTS |
3 |
0 |
0 |
|
|
248037852 |
C102063 |
A |
Feb. 24, 2024, 3:31 a.m. |
OK |
GNU C++17 (64) |
TESTS |
3 |
0 |
0 |
|
|
248040537 |
Lemon-Tree |
A |
Feb. 24, 2024, 4:12 a.m. |
OK |
GNU C++17 (64) |
TESTS |
3 |
0 |
0 |
|
|
248042851 |
superabound |
A |
Feb. 24, 2024, 4:44 a.m. |
OK |
GNU C++17 (64) |
TESTS |
3 |
0 |
0 |
|
|
248048962 |
Dark--------Shadow |
A |
Feb. 24, 2024, 5:50 a.m. |
OK |
GNU C++20 (64) |
TESTS |
3 |
0 |
0 |
|
|
248048874 |
secretman1312 |
A |
Feb. 24, 2024, 5:50 a.m. |
OK |
GNU C++20 (64) |
TESTS |
3 |
0 |
0 |
|
|
248047670 |
h_psi_t |
A |
Feb. 24, 2024, 5:38 a.m. |
OK |
GNU C++20 (64) |
TESTS |
3 |
0 |
0 |
|
|
248047330 |
ninjamayank |
A |
Feb. 24, 2024, 5:35 a.m. |
OK |
GNU C++20 (64) |
TESTS |
3 |
0 |
0 |
|
|
248046808 |
adelian |
A |
Feb. 24, 2024, 5:30 a.m. |
OK |
GNU C++20 (64) |
TESTS |
3 |
0 |
0 |
|
|
248045761 |
N1664 |
A |
Feb. 24, 2024, 5:18 a.m. |
OK |
GNU C++20 (64) |
TESTS |
3 |
0 |
0 |
|
|
248045606 |
Sorafuyu |
A |
Feb. 24, 2024, 5:16 a.m. |
OK |
GNU C++20 (64) |
TESTS |
3 |
0 |
0 |
|
|
248045007 |
Arvin_2024target_CM |
A |
Feb. 24, 2024, 5:09 a.m. |
OK |
GNU C++20 (64) |
TESTS |
3 |
0 |
0 |
|
|
248044785 |
nitin_kumar_t_27 |
A |
Feb. 24, 2024, 5:07 a.m. |
OK |
GNU C++20 (64) |
TESTS |
3 |
0 |
0 |
|
|
248044599 |
Atmchik |
A |
Feb. 24, 2024, 5:05 a.m. |
OK |
GNU C++20 (64) |
TESTS |
3 |
0 |
0 |
|
|
247978944 |
ajayg3059 |
A |
Feb. 23, 2024, 4:36 p.m. |
OK |
Go |
TESTS |
3 |
15 |
409600 |
|
|
248003092 |
AkshatSaxena_05 |
A |
Feb. 23, 2024, 6:56 p.m. |
OK |
Java 21 |
TESTS |
3 |
186 |
409600 |
|
|
247981070 |
Pradeep880 |
A |
Feb. 23, 2024, 4:43 p.m. |
OK |
Java 21 |
TESTS |
3 |
202 |
0 |
|
|
248035484 |
fabiowg |
A |
Feb. 24, 2024, 2:53 a.m. |
OK |
Java 21 |
TESTS |
3 |
202 |
819200 |
|
|
248005653 |
malaklabib |
A |
Feb. 23, 2024, 7:16 p.m. |
OK |
Java 21 |
TESTS |
3 |
218 |
204800 |
|
|
247994637 |
shaili17 |
A |
Feb. 23, 2024, 5:58 p.m. |
OK |
Java 21 |
TESTS |
3 |
218 |
204800 |
|
|
248004671 |
saraelshafie |
A |
Feb. 23, 2024, 7:08 p.m. |
OK |
Java 21 |
TESTS |
3 |
233 |
307200 |
|
|
248040754 |
codeWithDarshan |
A |
Feb. 24, 2024, 4:15 a.m. |
OK |
Java 21 |
TESTS |
3 |
234 |
0 |
|
|
247984553 |
arafateasin.bn |
A |
Feb. 23, 2024, 4:57 p.m. |
OK |
Java 21 |
TESTS |
3 |
249 |
0 |
|
|
248030672 |
kbliu |
A |
Feb. 24, 2024, 1:07 a.m. |
OK |
Java 21 |
TESTS |
3 |
249 |
204800 |
|
|
248041031 |
iknownothing13 |
A |
Feb. 24, 2024, 4:19 a.m. |
OK |
Java 21 |
TESTS |
3 |
264 |
512000 |
|
|
248008111 |
dhaval_lila |
A |
Feb. 23, 2024, 7:35 p.m. |
OK |
Java 8 |
TESTS |
3 |
93 |
0 |
|
|
247997304 |
Mr.Numerator_007 |
A |
Feb. 23, 2024, 6:16 p.m. |
OK |
Java 8 |
TESTS |
3 |
93 |
0 |
|
|
247979250 |
Kuuuuuuuuu |
A |
Feb. 23, 2024, 4:37 p.m. |
OK |
Java 8 |
TESTS |
3 |
108 |
0 |
|
|
248039636 |
tinku_vishnu |
A |
Feb. 24, 2024, 3:58 a.m. |
OK |
Java 8 |
TESTS |
3 |
109 |
0 |
|
|
248014117 |
Sumitsingh7 |
A |
Feb. 23, 2024, 8:31 p.m. |
OK |
Java 8 |
TESTS |
3 |
109 |
6348800 |
|
|
247997202 |
abhayrajnegi0416 |
A |
Feb. 23, 2024, 6:15 p.m. |
OK |
Java 8 |
TESTS |
3 |
124 |
0 |
|
|
248005516 |
mada-mada |
A |
Feb. 23, 2024, 7:15 p.m. |
OK |
Java 8 |
TESTS |
3 |
139 |
0 |
|
|
247998079 |
abhayrajnegi0416 |
A |
Feb. 23, 2024, 6:21 p.m. |
OK |
Java 8 |
TESTS |
3 |
139 |
0 |
|
|
248028365 |
alfazkherani |
A |
Feb. 24, 2024, 12:13 a.m. |
OK |
Java 8 |
TESTS |
3 |
156 |
0 |
|
|
248045530 |
218r1a05d2 |
A |
Feb. 24, 2024, 5:15 a.m. |
OK |
Java 8 |
TESTS |
3 |
170 |
0 |
|
|
247993622 |
serg_alb |
A |
Feb. 23, 2024, 5:51 p.m. |
OK |
Kotlin 1.7 |
TESTS |
3 |
295 |
8806400 |
|
|
248004396 |
Crazy67 |
A |
Feb. 23, 2024, 7:06 p.m. |
OK |
Kotlin 1.9 |
TESTS |
3 |
108 |
0 |
|
|
248041143 |
anuragpandey87187 |
A |
Feb. 24, 2024, 4:21 a.m. |
OK |
Kotlin 1.9 |
TESTS |
3 |
155 |
102400 |
|
|
247981635 |
Aneeba |
A |
Feb. 23, 2024, 4:45 p.m. |
OK |
MS C++ 2017 |
TESTS |
3 |
30 |
0 |
|
|
248016186 |
Sofi_ |
A |
Feb. 23, 2024, 8:53 p.m. |
OK |
MS C++ 2017 |
TESTS |
3 |
31 |
0 |
|
|
248022656 |
kaaamKaaaam |
A |
Feb. 23, 2024, 10:17 p.m. |
OK |
MS C++ 2017 |
TESTS |
3 |
31 |
0 |
|
|
248001513 |
afwull |
A |
Feb. 23, 2024, 6:45 p.m. |
OK |
MS C++ 2017 |
TESTS |
3 |
46 |
0 |
|
|
248047992 |
vikaskajla |
A |
Feb. 24, 2024, 5:41 a.m. |
OK |
Node.js |
TESTS |
3 |
93 |
2457600 |
|
|
248008786 |
Oleg1999 |
A |
Feb. 23, 2024, 7:41 p.m. |
OK |
PascalABC.NET |
TESTS |
3 |
155 |
0 |
|
|
247986809 |
crapcode |
A |
Feb. 23, 2024, 5:08 p.m. |
OK |
PHP |
TESTS |
3 |
15 |
0 |
|
|
247978577 |
Fatima526 |
A |
Feb. 23, 2024, 4:34 p.m. |
OK |
PyPy 3 |
TESTS |
3 |
155 |
5017600 |
|
|
248047258 |
Nhannghia2007 |
A |
Feb. 24, 2024, 5:34 a.m. |
OK |
PyPy 3 |
TESTS |
3 |
186 |
5939200 |
|
|
247991611 |
213t1a0423 |
A |
Feb. 23, 2024, 5:38 p.m. |
OK |
PyPy 3 |
TESTS |
3 |
202 |
4812800 |
|
|
248010753 |
dishanth0282 |
A |
Feb. 23, 2024, 7:59 p.m. |
OK |
PyPy 3-64 |
TESTS |
3 |
62 |
1740800 |
|
|
247982849 |
yertugan06 |
A |
Feb. 23, 2024, 4:49 p.m. |
OK |
PyPy 3-64 |
TESTS |
3 |
77 |
2355200 |
|
|
248009485 |
NitroSpear |
A |
Feb. 23, 2024, 7:47 p.m. |
OK |
PyPy 3-64 |
TESTS |
3 |
77 |
2457600 |
|
|
248009375 |
NitroSpear |
A |
Feb. 23, 2024, 7:46 p.m. |
OK |
PyPy 3-64 |
TESTS |
3 |
77 |
2764800 |
|
|
248009260 |
NitroSpear |
A |
Feb. 23, 2024, 7:45 p.m. |
OK |
PyPy 3-64 |
TESTS |
3 |
77 |
3379200 |
|
|
248008221 |
jvatsal0709 |
A |
Feb. 23, 2024, 7:36 p.m. |
OK |
PyPy 3-64 |
TESTS |
3 |
77 |
3993600 |
|
|
248040028 |
Neffus |
A |
Feb. 24, 2024, 4:04 a.m. |
OK |
PyPy 3-64 |
TESTS |
3 |
77 |
4608000 |
|
|
248036751 |
tlsgusrb314 |
A |
Feb. 24, 2024, 3:13 a.m. |
OK |
PyPy 3-64 |
TESTS |
3 |
77 |
4710400 |
|
|
248009464 |
NitroSpear |
A |
Feb. 23, 2024, 7:47 p.m. |
OK |
PyPy 3-64 |
TESTS |
3 |
93 |
2560000 |
|
|
247992231 |
find |
A |
Feb. 23, 2024, 5:42 p.m. |
OK |
PyPy 3-64 |
TESTS |
3 |
93 |
3481600 |
|
|
248026896 |
OLOGY |
A |
Feb. 23, 2024, 11:39 p.m. |
OK |
Python 2 |
TESTS |
3 |
31 |
409600 |
|
|
248007823 |
eugalt |
A |
Feb. 23, 2024, 7:33 p.m. |
OK |
Python 3 |
TESTS |
3 |
30 |
102400 |
|
|
247995380 |
Alive_but_not_living |
A |
Feb. 23, 2024, 6:03 p.m. |
OK |
Python 3 |
TESTS |
3 |
30 |
102400 |
|
|
247978212 |
alexander.calvin98 |
A |
Feb. 23, 2024, 4:34 p.m. |
OK |
Python 3 |
TESTS |
3 |
31 |
0 |
|
|
248045748 |
aritro_pal |
A |
Feb. 24, 2024, 5:18 a.m. |
OK |
Python 3 |
TESTS |
3 |
31 |
102400 |
|
|
248024497 |
khan_shahrukh |
A |
Feb. 23, 2024, 10:51 p.m. |
OK |
Python 3 |
TESTS |
3 |
31 |
102400 |
|
|
248011297 |
xMakuno |
A |
Feb. 23, 2024, 8:04 p.m. |
OK |
Python 3 |
TESTS |
3 |
31 |
102400 |
|
|
248011071 |
abeni505 |
A |
Feb. 23, 2024, 8:01 p.m. |
OK |
Python 3 |
TESTS |
3 |
31 |
102400 |
|
|
248005543 |
MinakoKojima |
A |
Feb. 23, 2024, 7:15 p.m. |
OK |
Python 3 |
TESTS |
3 |
31 |
102400 |
|
|
247986691 |
saigumma |
A |
Feb. 23, 2024, 5:07 p.m. |
OK |
Python 3 |
TESTS |
3 |
31 |
102400 |
|
|
248039488 |
Xia21 |
A |
Feb. 24, 2024, 3:56 a.m. |
OK |
Python 3 |
TESTS |
3 |
46 |
0 |
|
|
247983322 |
0x81 |
A |
Feb. 23, 2024, 4:51 p.m. |
OK |
Ruby 3 |
TESTS |
3 |
468 |
716800 |
|
|
248027272 |
DMMenezes |
A |
Feb. 23, 2024, 11:47 p.m. |
OK |
Rust 2021 |
TESTS |
3 |
15 |
0 |
|
|
247981396 |
Hyrulia |
A |
Feb. 23, 2024, 4:44 p.m. |
OK |
Rust 2021 |
TESTS |
3 |
15 |
307200 |
|
|
remove filters
Back to search problems