Codeforces Round 1037 (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
2126 Codeforces Round 1037 (Div. 3) FINISHED False 8100 23642723 July 17, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 2468 ) G1 Big Wins! (easy version) PROGRAMMING binary search binary search two pointers

This is the easy version of the problem. The difference between the versions is that in this version (a_i \leq \min(n,100)). You are given an array of (n) integers (a_1, a_2, \dots, a_n). Your task is to find a subarray (al, r) (a continuous sequence of elements (a_l, a_{l + 1}, \dots, a_r)) for which the value of the expression (\text{med}(al, r) - \min(al, r)) is maximized. Here: (\text{med}) — the median of the subarray, which is the element at position (\left\lceil \frac{k + 1}{2} \right\rceil) after sorting the subarray, where (k) is its length; (\min) — the minimum element of this subarray. For example, consider the array (a=1, 4, 1, 5, 3, 3) and choose the subarray (a2, 5 = 4, 1, 5, 3). In sorted form, it looks like (1, 3, 4, 5). (\text{med}(a2, 5) = 4), since (\left\lceil \frac{4 + 1}{2} \right\rceil =) the third element in the sorted subarray is (4); (\min(a2, 5) = 1), since the minimum element is (1). In this example, the value (\text{med} - \min = 4 - 1 = 3). The first line contains an integer (t) ((1 \le t \le 10^4)) — the number of test cases. The first line of each test case contains one integer (n) ((1 \leq n \leq 2 \cdot 10^5)) — the length of the array. The second line of each test case contains (n) integers (a_1, a_2, \dots, a_n) ((1 \leq a_i \leq \min(n, 100))) — the elements of the array. It is guaranteed that the sum of (n) across all test cases does not exceed (2 \cdot 10^5). For each test case, output a single integer — the maximum possible value of (\text{med} - \min) among all subarrays of the array. In the first example, consider the array: (a=3,\ 2,\ 5,\ 3,\ 1) you can choose the subarray (a2,\ 3), which consists of the elements (2,\ 5). The length of the subarray is (2). The median is the element at position (\left\lceil \dfrac{3}{2} \right\rceil = 2) in the sorted subar

Tutorials

144845

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
329526414 -firefly- G1 July 17, 2025, 5:15 p.m. OK C# 13 TESTS 18 234 6144000
329538915 AtulJ1314 G1 July 17, 2025, 6:50 p.m. OK C++17 (GCC 7-32) TESTS 18 124 0
329559906 xxxtk G1 July 18, 2025, 1:19 a.m. OK C++17 (GCC 7-32) TESTS 18 202 6451200
329571766 linyihdfj G1 July 18, 2025, 3:27 a.m. OK C++17 (GCC 7-32) TESTS 18 249 16076800
329550619 Dhruthi_MS G1 July 17, 2025, 9:18 p.m. OK C++17 (GCC 7-32) TESTS 18 265 307200
329579693 ywjylx G1 July 18, 2025, 5:04 a.m. OK C++17 (GCC 7-32) TESTS 18 265 11264000
329528944 Just_a_dude2 G1 July 17, 2025, 5:31 p.m. OK C++17 (GCC 7-32) TESTS 18 281 48128000
329559599 Luvidi G1 July 18, 2025, 1:13 a.m. OK C++17 (GCC 7-32) TESTS 18 296 13926400
329526385 zygo G1 July 17, 2025, 5:15 p.m. OK C++17 (GCC 7-32) TESTS 18 311 5120000
329573521 AmnO-O G1 July 18, 2025, 3:47 a.m. OK C++17 (GCC 7-32) TESTS 18 327 2457600
329582653 ayshrnjn G1 July 18, 2025, 5:37 a.m. OK C++17 (GCC 7-32) TESTS 18 358 3276800
329576295 yxfql G1 July 18, 2025, 4:23 a.m. OK C++20 (GCC 13-64) TESTS 18 93 1945600
329576810 Socialfox123 G1 July 18, 2025, 4:29 a.m. OK C++20 (GCC 13-64) TESTS 18 109 102400
329546803 Znno G1 July 17, 2025, 8:18 p.m. OK C++20 (GCC 13-64) TESTS 18 140 0
329584001 Kartik77 G1 July 18, 2025, 5:50 a.m. OK C++20 (GCC 13-64) TESTS 18 140 102400
329560960 pipipipipi43 G1 July 18, 2025, 1:37 a.m. OK C++20 (GCC 13-64) TESTS 18 140 102400
329556682 HowToLearnML G1 July 18, 2025, 12:06 a.m. OK C++20 (GCC 13-64) TESTS 18 156 6041600
329528300 anitshah702 G1 July 17, 2025, 5:27 p.m. OK C++20 (GCC 13-64) TESTS 18 171 0
329544380 ahmetalp G1 July 17, 2025, 7:47 p.m. OK C++20 (GCC 13-64) TESTS 18 171 2764800
329532038 WisdomCasual G1 July 17, 2025, 5:52 p.m. OK C++20 (GCC 13-64) TESTS 18 187 819200
329574790 I_love_maxaxaxaxa G1 July 18, 2025, 4:03 a.m. OK C++20 (GCC 13-64) TESTS 18 202 102400
329571373 Aword G1 July 18, 2025, 3:23 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 77 1945600
329576263 nhan0123456 G1 July 18, 2025, 4:22 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 77 4915200
329541484 postpone G1 July 17, 2025, 7:16 p.m. OK C++23 (GCC 14-64, msys2) TESTS 18 78 2048000
329543774 Jasonwei08 G1 July 17, 2025, 7:40 p.m. OK C++23 (GCC 14-64, msys2) TESTS 18 92 7680000
329532591 Firefly_2025target_GM G1 July 17, 2025, 5:56 p.m. OK C++23 (GCC 14-64, msys2) TESTS 18 93 1228800
329573379 A.I.skeleton_ G1 July 18, 2025, 3:45 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 93 4403200
329541117 Auchenai01 G1 July 17, 2025, 7:12 p.m. OK C++23 (GCC 14-64, msys2) TESTS 18 109 6041600
329551521 Eulers_Tour G1 July 17, 2025, 9:35 p.m. OK C++23 (GCC 14-64, msys2) TESTS 18 124 2867200
329582344 1egend G1 July 18, 2025, 5:33 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 155 0
329580338 bundblaster2003 G1 July 18, 2025, 5:11 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 156 4300800
329525370 longtep G1 July 17, 2025, 5:10 p.m. OK FPC TESTS 18 171 102400
329569227 oneafter G1 July 18, 2025, 3:03 a.m. OK Java 21 TESTS 18 1968 1740800
329540277 kasiru_69 G1 July 17, 2025, 7:03 p.m. OK Java 8 TESTS 18 499 7270400
329579733 not_mohith G1 July 18, 2025, 5:04 a.m. OK Java 8 TESTS 18 640 0
329542498 BOT_DURGESH1 G1 July 17, 2025, 7:27 p.m. OK PyPy 3-64 TESTS 18 952 40243200
329553822 Alex239 G1 July 17, 2025, 10:36 p.m. OK PyPy 3-64 TESTS 18 1484 110796800
329555195 ChickenTamer G1 July 17, 2025, 11:15 p.m. OK PyPy 3-64 TESTS 18 2515 31334400
329553948 JakeMate14 G1 July 17, 2025, 10:40 p.m. OK Rust 2021 TESTS 18 953 30310400

remove filters

Back to search problems