Codeforces Round 787 (Div. 3)

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
1675 Codeforces Round 787 (Div. 3) FINISHED False 8100 80061899 May 5, 2022, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 1784 ) G Sorting Pancakes PROGRAMMING dp

B'Nastya baked m pancakes and spread them on n dishes. The dishes are in a row and numbered from left to right. She put a_i pancakes on the dish with the index i . Seeing the dishes, Vlad decided to bring order to the stacks and move some pancakes. In one move, he can shift one pancake from any dish to the closest one, that is, select the dish i ( a_i > 0 ) and do one of the following: Vlad wants to make the array a non-increasing, after moving as few pancakes as possible. Help him find the minimum number of moves needed for this. The array a=[a_1, a_2, ... ,a_n] is called non-increasing if a_i ge a_{i+1} for all i from 1 to n-1 . The first line of the input contains two numbers n and m ( 1 <= n, m <= 250 ) -- the number of dishes and the number of pancakes, respectively. The second line contains n numbers a_i ( 0 <= a_i <= m ), the sum of all a_i is equal to m . Print a single number: the minimum number of moves required to make the array a non-increasing. In the first example, you first need to move the pancake from the dish 1 , after which a = [4, 4, 2, 3, 3, 3] . After that, you need to move the pancake from the dish 2 to the dish 3 and the array will become non-growing a = [4, 3, 3, 3, 3, 3] . '...

Tutorials

102550

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
156006069 Gassa G May 5, 2022, 4:47 p.m. OK D TESTS 58 31 1945600

remove filters

Back to search problems