Codeforces Round 1039 (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
2128 Codeforces Round 1039 (Div. 2) FINISHED False 7200 22778723 July 27, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 6512 ) E1 Submedians (Easy Version) PROGRAMMING binary search data structures dp greedy

This is the easy version of the problem. The only difference is that in this version, you are asked to find a subarray only for the maximum submedian . You can make hacks only if both versions of the problem are solved. An integer (v) is a median of an array (b) of length (m) if and only if: (v) is greater than or equal to at least (\lceil \frac{m}{2} \rceil) elements of the array, and (v) is less than or equal to at least (\lceil \frac{m}{2} \rceil) elements of the array. the only median of (9, 3, 7) is (7), the medians of (5, 3, 7, 9) are (5), (6), and (7), and the only median of (2, 2, 2) is (2). You're given an integer (k) and an array (a_1, \ldots, a_n) of integers between (1) and (n). An integer (v) from (1) to (n) is said to be a submedian if there exists at least one pair of indices ((l, r)) such that (1 \leq l \leq r \leq n), (r - l + 1 \geq k), (v) is a median of the subarray (a_l, \ldots, a_r). It can be proven that there always exists at least one submedian . Find the maximum submedian (v_\max) and any corresponding pair of indices ((l, r)). Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 50\,000)). The description of the test cases follows. The first line of each test case contains two integers (n) and (k) ((1 \leq k \leq n \leq 300\,000)). The second line of each test case contains (n) integers (a_1, a_2, \ldots, a_n) ((1 \leq a_i \leq n)). It is guaranteed that the sum of (n) over all test cases doesn't exceed (300\,000). For each test case, output three integers (v_\max), (l), and (r) — the maximum submedian (v_\max) and the bounds of a subarray of length at least (k) ((r - l + 1 \geq k)) such that (v_\max) is one of its medians . If there are many solutions, you can print any of them. In the f

Tutorials

Codeforces Round #1039 — Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
331232340 CodeDominator123 E1 July 28, 2025, 2:18 a.m. OK C++17 (GCC 7-32) TESTS 23 109 2457600
331232963 djn123 E1 July 28, 2025, 2:26 a.m. OK C++17 (GCC 7-32) TESTS 23 109 4096000
331211697 Formatci E1 July 27, 2025, 8:15 p.m. OK C++17 (GCC 7-32) TESTS 23 124 0
331193108 Masan E1 July 27, 2025, 5:25 p.m. OK C++17 (GCC 7-32) TESTS 23 124 2457600
331224529 WorldShine03 E1 July 28, 2025, 12:30 a.m. OK C++17 (GCC 7-32) TESTS 23 124 2457600
331224454 WorldShine02 E1 July 28, 2025, 12:28 a.m. OK C++17 (GCC 7-32) TESTS 23 124 2457600
331238166 J_u E1 July 28, 2025, 3:34 a.m. OK C++17 (GCC 7-32) TESTS 23 124 4812800
331230933 hgzx E1 July 28, 2025, 2 a.m. OK C++17 (GCC 7-32) TESTS 23 124 4915200
331236513 cimcle E1 July 28, 2025, 3:12 a.m. OK C++17 (GCC 7-32) TESTS 23 125 1126400
331236375 dijaschua E1 July 28, 2025, 3:10 a.m. OK C++17 (GCC 7-32) TESTS 23 125 1126400
331223134 TataneSan E1 July 27, 2025, 11:55 p.m. OK C++20 (GCC 13-64) TESTS 23 93 102400
331235919 akshil_ahuja E1 July 28, 2025, 3:04 a.m. OK C++20 (GCC 13-64) TESTS 23 108 0
331230298 ymh114514 E1 July 28, 2025, 1:52 a.m. OK C++20 (GCC 13-64) TESTS 23 108 2457600
331247429 MD.Abdullah E1 July 28, 2025, 5:43 a.m. OK C++20 (GCC 13-64) TESTS 23 108 3686400
331235452 tnhwe E1 July 28, 2025, 2:58 a.m. OK C++20 (GCC 13-64) TESTS 23 108 12083200
331205238 Sokol080808 E1 July 27, 2025, 7:01 p.m. OK C++20 (GCC 13-64) TESTS 23 109 0
331229199 August61945 E1 July 28, 2025, 1:36 a.m. OK C++20 (GCC 13-64) TESTS 23 109 102400
331238660 calm_focus E1 July 28, 2025, 3:40 a.m. OK C++20 (GCC 13-64) TESTS 23 109 102400
331222861 TahsinArafat E1 July 27, 2025, 11:47 p.m. OK C++20 (GCC 13-64) TESTS 23 109 102400
331241747 zhangjinxi E1 July 28, 2025, 4:26 a.m. OK C++20 (GCC 13-64) TESTS 23 109 2048000
331209597 2304 E1 July 27, 2025, 7:50 p.m. OK C++23 (GCC 14-64, msys2) TESTS 23 108 4198400
331239451 zhiye E1 July 28, 2025, 3:51 a.m. OK C++23 (GCC 14-64, msys2) TESTS 23 109 102400
331241494 zhiye E1 July 28, 2025, 4:22 a.m. OK C++23 (GCC 14-64, msys2) TESTS 23 109 102400
331229767 enslaved E1 July 28, 2025, 1:44 a.m. OK C++23 (GCC 14-64, msys2) TESTS 23 109 102400
331231737 gaojtccc E1 July 28, 2025, 2:10 a.m. OK C++23 (GCC 14-64, msys2) TESTS 23 109 1228800
331188598 Marckess E1 July 27, 2025, 4:33 p.m. OK C++23 (GCC 14-64, msys2) TESTS 23 109 2457600
331214363 cybr0g E1 July 27, 2025, 8:50 p.m. OK C++23 (GCC 14-64, msys2) TESTS 23 124 0
331249485 Arvi_saleque E1 July 28, 2025, 6:05 a.m. OK C++23 (GCC 14-64, msys2) TESTS 23 124 0
331235120 Rating_10101010 E1 July 28, 2025, 2:54 a.m. OK C++23 (GCC 14-64, msys2) TESTS 23 124 0
331233343 Kristiana E1 July 28, 2025, 2:31 a.m. OK C++23 (GCC 14-64, msys2) TESTS 23 124 0
331183016 James_bond_9089 E1 July 27, 2025, 4:23 p.m. OK C# 8 TESTS 23 249 36044800
331193498 pengin_2000 E1 July 27, 2025, 5:27 p.m. OK GNU C11 TESTS 23 155 2457600
331212723 avighnakc E1 July 27, 2025, 8:26 p.m. OK GNU C11 TESTS 23 265 3686400
331183313 Yoda1122 E1 July 27, 2025, 4:24 p.m. OK Java 21 TESTS 23 327 716800
331203709 redreoicy E1 July 27, 2025, 6:46 p.m. OK Java 21 TESTS 23 343 4096000
331194655 Franktastic E1 July 27, 2025, 5:34 p.m. OK Java 21 TESTS 23 390 5836800
331185195 Jien E1 July 27, 2025, 4:28 p.m. OK Java 21 TESTS 23 405 1433600
331184820 lupunish E1 July 27, 2025, 4:27 p.m. OK Java 21 TESTS 23 421 1638400
331238803 Chiffin E1 July 28, 2025, 3:43 a.m. OK Java 21 TESTS 23 500 6656000
331188430 xionghui E1 July 27, 2025, 4:33 p.m. OK Java 21 TESTS 23 874 4505600
331182833 HRishikesh7 E1 July 27, 2025, 4:23 p.m. OK Java 21 TESTS 23 905 1331200
331209230 kasiru_69 E1 July 27, 2025, 7:45 p.m. OK Java 8 TESTS 23 359 29696000
331187958 rishi_140603 E1 July 27, 2025, 4:32 p.m. OK Java 8 TESTS 23 405 22118400
331241082 rutul21 E1 July 28, 2025, 4:16 a.m. OK Java 8 TESTS 23 656 0
331225754 Remineva E1 July 28, 2025, 12:46 a.m. OK PyPy 3-64 TESTS 23 312 44544000
331203877 x3mka E1 July 27, 2025, 6:48 p.m. OK PyPy 3-64 TESTS 23 312 45568000
331222917 SrEy_P-0-7 E1 July 27, 2025, 11:49 p.m. OK PyPy 3-64 TESTS 23 312 49152000
331185431 shivamsai006 E1 July 27, 2025, 4:28 p.m. OK PyPy 3-64 TESTS 23 327 50995200
331207964 dalgu_py E1 July 27, 2025, 7:31 p.m. OK PyPy 3-64 TESTS 23 327 74035200
331237933 von2401 E1 July 28, 2025, 3:30 a.m. OK PyPy 3-64 TESTS 23 342 46284800
331186392 leqkoplastir E1 July 27, 2025, 4:30 p.m. OK PyPy 3-64 TESTS 23 343 50995200
331216122 DarkTemplarDrop E1 July 27, 2025, 9:20 p.m. OK PyPy 3-64 TESTS 23 359 47820800
331189567 Pie854 E1 July 27, 2025, 4:34 p.m. OK PyPy 3-64 TESTS 23 390 42598400
331239268 yiren429 E1 July 28, 2025, 3:49 a.m. OK PyPy 3-64 TESTS 23 452 38604800
331185103 sakshamkapoor810 E1 July 27, 2025, 4:27 p.m. OK Python 3 TESTS 23 1499 34816000
331182967 lowest_contribution E1 July 27, 2025, 4:23 p.m. OK Python 3 TESTS 23 1671 35020800
331184078 KAI_1 E1 July 27, 2025, 4:25 p.m. OK Python 3 TESTS 23 2030 34816000
331184534 Digamber_2522 E1 July 27, 2025, 4:26 p.m. OK Python 3 TESTS 23 2124 42188800
331184381 Darkcoder404 E1 July 27, 2025, 4:26 p.m. OK Python 3 TESTS 23 2468 34816000
331210889 Rcrocks E1 July 27, 2025, 8:06 p.m. OK Python 3 TESTS 23 2983 40140800
331186581 huixiong E1 July 27, 2025, 4:30 p.m. OK Rust 2021 TESTS 23 218 4710400

remove filters

Back to search problems