Codeforces Round 1045 (Div. 2)

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
2134 Codeforces Round 1045 (Div. 2) FINISHED False 7200 20186723 Aug. 26, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 18562 ) C Even Larger PROGRAMMING greedy greedy

An array is called good if, for every subarray(^{\text{∗}}) of length at least (2), the sum of the elements at even indices (with respect to the original array ) is greater than or equal to the sum of the elements at odd indices. Array indexing starts from (1). For example, the arrays (3,8,4,4) and (2,3,1,4,2) are good. The array (0,2,4,1) is not because, in the subarray (2,4,1), the elements at even indices in the original array are (2) (index (2)) and (1) (index (4)), while the only element at an odd index is (4) (index (3)). Since (2 + 1 < 4), the condition does not hold for this subarray. You are given an array of (n) non-negative integers (a_1,a_2,\ldots,a_n). In one operation, you can decrease any element in the array by (1), but all elements must remain non-negative . Your task is to find the minimum number of operations needed to make the array (a) good. It can be proved that it is possible to make the array good using a finite number of operations. (^{\text{∗}})An array (b) is a subarray of an array (a) if (b) can be obtained from (a) by the deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^4)). The description of the test cases follows. The first line of each test case contains a single integer (n) ((2 \le n \le 2 \cdot 10^5)) — the length of the array (a). The second line of each test case contains (n) non-negative integers (a_1,a_2,\ldots,a_n) ((0 \le a_i \le 10^9)) — the elements of the array (a). It is guaranteed that the sum of (n) over all test cases does not exceed (2 \cdot 10^5). For each test case, output a single integer in a new line — the minimum number of operations needed to make the array (a) good.

Tutorials

145832

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
335711652 og.kostya C Aug. 26, 2025, 5:57 p.m. OK C# 13 TESTS 20 155 2150400

remove filters

Back to search problems