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 |
---|---|---|---|---|---|---|
1746 | Codeforces Global Round 23 | FINISHED | False | 8100 | 65978699 | Oct. 15, 2022, 2:35 p.m. |
Solved$ |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
---|---|---|---|---|---|---|
( 17257 ) | B | Rebellion | PROGRAMMING | constructive algorithms greedy |
B"You have an array a of size n consisting only of zeroes and ones. You can do the following operation: Note that elements of a can become bigger than 1 after performing some operations. Also note that n becomes 1 less after the operation. What is the minimum number of operations needed to make a non-decreasing, i. e. that each element is not less than the previous element? Each test contains multiple test cases. The first line contains the number of test cases t ( 1 <= t <= 10^4 ). The description of the test cases follows. The first line of each test case contains an integer n ( 1 <= n <= 10^5 ), the size of array a . Next line contains n integers a_{1}, a_{2}, ldots a_{n} ( a_i is 0 or 1 ), elements of array a . It's guaranteed that sum of n over all test cases doesn't exceed 2 cdot 10^5 . For each test case print a single integer, minimum number of operations needed to make a non-decreasing. In the first test case, a is already non-decreasing, so you don't need to do any operations and the answer is 0 . In the second test case, you can perform an operation for i = 1 and j = 5 , so a will be equal to [0, 0, 1, 2] and it becomes non-decreasing. In the third test case, you can perform an operation for i = 2 and j = 1 , so a will be equal to [1] and it becomes non-decreasing. "... |
Codeforces Global Round 23 Editorial |
No solutions yet.