2024-2025 ICPC, NERC, Southern and Volga Russian Regional Contest (Unrated, Online Mirror, ICPC Rules, Preferably Teams)

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
2038 2024-2025 ICPC, NERC, Southern and Volga Russian Regional Contest (Unrated, Online Mirror, ICPC Rules, Preferably Teams) FINISHED False 18000 44479523 Nov. 18, 2024, 10:35 a.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 1904 ) B Make It Equal PROGRAMMING binary search brute force greedy math 2100

You are given an integer array (a) of size (n). The elements of the array are numbered from (1) to (n). You can perform the following operation any number of times (possibly, zero): choose an index (i) from (1) to (n); decrease (a_i) by (2) and increase (a_{(i \bmod n) + 1}) by (1). After you perform the operations, all elements of the array should be non-negative equal integers . Your task is to calculate the minimum number of operations you have to perform. The first line contains a single integer (t) ((1 \le t \le 10^4)) — the number of test cases. The first line of each test case contains a single integer (n) ((2 \le n \le 2 \cdot 10^5)). The second line of each test case contains (n) integers (a_1, a_2, \dots, a_n) ((1 \le a_i \le 10^9)). Additional constraint on the input: the sum of (n) over all test cases doesn't exceed (2 \cdot 10^5). For each test case, print a single integer — the minimum number of operations you have to perform. If it is impossible to make all elements of the array equal, print -1 .

Tutorials

Submissions

No solutions yet.