Refact.ai Match 1 (Codeforces Round 985)

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
2029 Refact.ai Match 1 (Codeforces Round 985) FINISHED False 10800 45242723 Nov. 9, 2024, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 146 ) I Variance Challenge PROGRAMMING flows graphs greedy

Kevin has recently learned the definition of variance. For an array (a) of length (n), the variance of (a) is defined as follows: Let (x=\dfrac{1}{n}\displaystyle\sum_{i=1}^n a_i), i.e., (x) is the mean of the array (a); Then, the variance of (a) is () V(a)=\frac{1}{n}\sum_{i=1}^n(a_i-x)^2. () Now, Kevin gives you an array (a) consisting of (n) integers, as well as an integer (k). You can perform the following operation on (a): Select an interval (l,r) ((1\le l\le r\le n)), then for each (l\le i\le r), increase (a_i) by (k). For each (1\le p\le m), you have to find the minimum possible variance of (a) after exactly (p) operations are performed, independently for each (p). For simplicity, you only need to output the answers multiplied by (n^2). It can be proven that the results are always integers. Each test contains multiple test cases. The first line of the input contains a single integer (t) ((1\le t\le 100)) — the number of test cases. The description of test cases follows. The first line of each test case contains three integers (n), (m), and (k) ((1\le n,m\le 5000), (\color{red}{n\cdot m\le 2\cdot 10^4}), (1\le k\le 10^5)) — the length of the array (a), the maximum number of operations, and the number you add to (a_i) each time, respectively. The second line contains (n) integers (a_1,a_2,\ldots, a_n) ((1\le a_i\le 10^5)) — the elements of the array (a). It is guaranteed that the sum of (n\cdot m) over all tests does not exceed (2\cdot 10^4). For each test case, output (m) integers in a single line, the (p)-th integer denoting the minimum possible variance of (a) when exactly (p) operations are performed, multiplied by (n^2). In the first test case: For (p = 1), you can perform the operation on (1, 1), changing (a) from (1, 2, 2) to (2, 2, 2). Since a

Tutorials

Refact.ai Match 1 (Codeforces Round 985) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
290806424 nbhoanh09hanoi I Nov. 10, 2024, 4:56 a.m. OK C++20 (GCC 13-64) TESTS 100 3061 102400
290774062 StellarSpecter I Nov. 9, 2024, 6:41 p.m. OK C++20 (GCC 13-64) TESTS 100 3108 102400
290784779 A_G I Nov. 9, 2024, 8:48 p.m. OK C++20 (GCC 13-64) TESTS 100 3249 102400
290783943 A_G I Nov. 9, 2024, 8:36 p.m. OK C++20 (GCC 13-64) TESTS 100 3827 102400
290774071 StellarSpecter I Nov. 9, 2024, 6:41 p.m. OK C++23 (GCC 14-64, msys2) TESTS 100 2890 102400
290774240 StellarSpecter I Nov. 9, 2024, 6:42 p.m. OK C++23 (GCC 14-64, msys2) TESTS 100 2905 102400
290773282 Ion_Gravirei I Nov. 9, 2024, 6:34 p.m. OK C++23 (GCC 14-64, msys2) TESTS 100 2905 102400
290772696 StellarSpecter I Nov. 9, 2024, 6:29 p.m. OK C++23 (GCC 14-64, msys2) TESTS 100 2905 102400
290772770 StellarSpecter I Nov. 9, 2024, 6:29 p.m. OK C++23 (GCC 14-64, msys2) TESTS 100 4327 102400
290771832 Benq I Nov. 9, 2024, 6:22 p.m. OK C++23 (GCC 14-64, msys2) TESTS 100 4327 102400

remove filters

Back to search problems