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.
ContestId |
Name |
Phase |
Frozen |
Duration (Seconds) |
Relative Time |
Start Time |
---|---|---|---|---|---|---|
1433 | Codeforces Round 677 (Div. 3) | FINISHED | False | 7200 | 128618699 | Oct. 20, 2020, 2:35 p.m. |
Solved$ |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
---|---|---|---|---|---|---|
( 28663 ) | B | Yet Another Bookshelf | PROGRAMMING | greedy implementation |
B'There is a bookshelf which can fit n books. The i -th position of bookshelf is a_i = 1 if there is a book on this position and a_i = 0 otherwise. It is guaranteed that there is at least one book on the bookshelf. In one move, you can choose some contiguous segment [l; r] consisting of books (i.e. for each i from l to r the condition a_i = 1 holds) and: Your task is to find the minimum number of moves required to collect all the books on the shelf as a contiguous (consecutive) segment (i.e. the segment without any gaps). For example, for a = [0, 0, 1, 0, 1] there is a gap between books ( a_4 = 0 when a_3 = 1 and a_5 = 1 ), for a = [1, 1, 0] there are no gaps between books and for a = [0, 0,0] there are also no gaps between books. You have to answer t independent test cases. The first line of the input contains one integer t ( 1 <= t <= 200 ) -- the number of test cases. Then t test cases follow. The first line of the test case contains one integer n ( 1 <= n <= 50 ) -- the number of places on a bookshelf. The second line of the test case contains n integers a_1, a_2, ldots, a_n ( 0 <= a_i <= 1 ), where a_i is 1 if there is a book at this position and 0 otherwise. It is guaranteed that there is at least one book on the bookshelf. For each test case, print one integer: the minimum number of moves required to collect all the books on the shelf as a contiguous (consecutive) segment (i.e. the segment without gaps). In the first test case of the example, you can shift the segment [3; 3] to the right and the segment [4; 5] to the right. After all moves, the books form the contiguous segment [5; 7] . So the answer is 2 . In the second test case of the example, you have nothing to do, all the books on the bookshelf form the contiguous segment already. In the third test case of the exam'... |
Codeforces Round #677 (Div. 3) Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
---|---|---|---|---|---|---|---|---|---|---|---|
96199046 | haiton2606 | B | Oct. 21, 2020, 3:15 a.m. | OK | FPC | TESTS | 3 | 15 | 0 | ||
96172292 | Charisma | B | Oct. 20, 2020, 5:23 p.m. | OK | GNU C++11 | TESTS | 2 | 0 | 0 | ||
96207083 | Fnrma | B | Oct. 21, 2020, 5:53 a.m. | OK | GNU C++11 | TESTS | 3 | 15 | 0 | ||
96206914 | SHN31 | B | Oct. 21, 2020, 5:50 a.m. | OK | GNU C++11 | TESTS | 3 | 15 | 0 | ||
96206474 | dreamsofcode | B | Oct. 21, 2020, 5:43 a.m. | OK | GNU C++11 | TESTS | 3 | 15 | 0 | ||
96206279 | jaswanth_20 | B | Oct. 21, 2020, 5:40 a.m. | OK | GNU C++11 | TESTS | 3 | 15 | 0 | ||
96203786 | wizard47 | B | Oct. 21, 2020, 4:59 a.m. | OK | GNU C++11 | TESTS | 3 | 15 | 0 | ||
96203227 | AkIoiAndNoi | B | Oct. 21, 2020, 4:50 a.m. | OK | GNU C++11 | TESTS | 3 | 15 | 0 | ||
96201437 | Opcode | B | Oct. 21, 2020, 4:10 a.m. | OK | GNU C++11 | TESTS | 3 | 15 | 0 | ||
96201538 | Saiyyamnitd | B | Oct. 21, 2020, 4:13 a.m. | OK | GNU C++11 | TESTS | 3 | 15 | 0 | ||
96207191 | JNU_dh_AK_WF | B | Oct. 21, 2020, 5:55 a.m. | OK | GNU C++11 | TESTS | 3 | 15 | 0 | ||
96162960 | felis | B | Oct. 20, 2020, 4:30 p.m. | OK | GNU C++14 | TESTS | 2 | 0 | 0 | ||
96171972 | aaditherise | B | Oct. 20, 2020, 5:20 p.m. | OK | GNU C++14 | TESTS | 2 | 0 | 0 | ||
96165849 | unique12 | B | Oct. 20, 2020, 4:36 p.m. | OK | GNU C++14 | TESTS | 2 | 0 | 0 | ||
96161998 | TheIncredibleVee | B | Oct. 20, 2020, 4:28 p.m. | OK | GNU C++14 | TESTS | 2 | 0 | 0 | ||
96205161 | songshichen | B | Oct. 21, 2020, 5:22 a.m. | OK | GNU C++14 | TESTS | 3 | 15 | 0 | ||
96207093 | shashi_fed | B | Oct. 21, 2020, 5:53 a.m. | OK | GNU C++14 | TESTS | 3 | 15 | 0 | ||
96206983 | Joth | B | Oct. 21, 2020, 5:51 a.m. | OK | GNU C++14 | TESTS | 3 | 15 | 0 | ||
96206738 | ckai2480 | B | Oct. 21, 2020, 5:47 a.m. | OK | GNU C++14 | TESTS | 3 | 15 | 0 | ||
96205686 | SrikarBegins | B | Oct. 21, 2020, 5:30 a.m. | OK | GNU C++14 | TESTS | 3 | 15 | 0 | ||
96205548 | priyesh_coder | B | Oct. 21, 2020, 5:28 a.m. | OK | GNU C++14 | TESTS | 3 | 15 | 0 | ||
96171084 | nemdavaa | B | Oct. 20, 2020, 5:13 p.m. | OK | .NET Core C# | TESTS | 2 | 77 | 204800 |
Back to search problems