Codeforces Round 1052 (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
2146 Codeforces Round 1052 (Div. 2) FINISHED False 8100 17940323 Sept. 21, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 2027 ) E Yet Another MEX Problem PROGRAMMING brute force constructive algorithms data structures greedy

We define the weight of an array (b) consisting of (m) non-negative integers as the number of indices (i) ((1\le i\le m)) satisfying (b_i>\operatorname{mex}(b)). Here, (\operatorname{mex}(b)) denotes the minimum excluded (MEX)(^{\text{∗}}) of the integers in (b). You are given an array (a) consisting of (n) non-negative integers. For its subarray(^{\text{†}}) (a_l, a_{l+1}, \ldots, a_r), we denote the weight of the subarray as (w(l,r)). For every (1\le i\le n), you have to find the maximum weight over all subarrays of (a) ending at index (i). In other words, you have to find (\max\limits_{1\le l\le i} w(l, i)) for every (1\le i\le n). (^{\text{∗}})The minimum excluded (MEX) of a collection of integers (b_1, b_2, \ldots, b_m) is defined as the smallest non-negative integer (x) which does not occur in the collection (b). (^{\text{†}})An array (c) is a subarray of an array (a) if (c) 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) ((1\le n \le 3\cdot 10^5)) — the length of (a). The second line contains (n) integers (a_1,a_2,\ldots,a_n) ((0\le a_i\le n)) — the elements of (a). It is guaranteed that the sum of (n) over all test cases does not exceed (3\cdot 10^5). For each test case, output (n) integers, the (i)-th integer denoting the maximum weight over all subarrays of (a) ending at index (i), i.e., (\max\limits_{1\le l\le i}w(l,i)). In the first test case, we have (w(1, 1) = 0), because (\operatorname{mex}(a_1) = 1), and there are no indices satis

Tutorials

Codeforces Round 1052 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
339820144 ggez09813 E Sept. 22, 2025, 2:48 a.m. OK C++17 (GCC 7-32) TESTS 27 187 10854400
339834016 zijinjun E Sept. 22, 2025, 5:51 a.m. OK C++17 (GCC 7-32) TESTS 27 218 6963200
339815948 gray114514 E Sept. 22, 2025, 1:51 a.m. OK C++17 (GCC 7-32) TESTS 27 218 6963200
339776136 int23_t E Sept. 21, 2025, 4:25 p.m. OK C++17 (GCC 7-32) TESTS 25 218 6963200
339777940 W_Poly E Sept. 21, 2025, 4:30 p.m. OK C++17 (GCC 7-32) TESTS 25 218 8192000
339777472 wahi_Piu E Sept. 21, 2025, 4:29 p.m. OK C++17 (GCC 7-32) TESTS 25 218 8192000
339820526 qjm E Sept. 22, 2025, 2:53 a.m. OK C++17 (GCC 7-32) TESTS 27 218 9625600
339781058 CuteJerry E Sept. 21, 2025, 4:40 p.m. OK C++17 (GCC 7-32) TESTS 25 233 6963200
339822889 zhangbh E Sept. 22, 2025, 3:28 a.m. OK C++17 (GCC 7-32) TESTS 27 233 9625600
339773463 KimikoLiliana E Sept. 21, 2025, 4:18 p.m. OK C++17 (GCC 7-32) TESTS 25 234 8192000
339823868 rzyyyy E Sept. 22, 2025, 3:43 a.m. OK C++20 (GCC 13-64) TESTS 27 156 9625600
339800876 negative-xp E Sept. 21, 2025, 7:32 p.m. OK C++20 (GCC 13-64) TESTS 27 171 2150400
339797186 deidei625 E Sept. 21, 2025, 6:45 p.m. OK C++20 (GCC 13-64) TESTS 26 171 6963200
339806232 Kanaifu E Sept. 21, 2025, 9:04 p.m. OK C++20 (GCC 13-64) TESTS 27 187 3584000
339820804 yeminghan E Sept. 22, 2025, 2:56 a.m. OK C++20 (GCC 13-64) TESTS 27 187 8396800
339811148 Caylex E Sept. 21, 2025, 11:41 p.m. OK C++20 (GCC 13-64) TESTS 27 187 11878400
339832722 kulovemi E Sept. 22, 2025, 5:36 a.m. OK C++20 (GCC 13-64) TESTS 27 187 17817600
339833541 tkt0506tkt E Sept. 22, 2025, 5:46 a.m. OK C++20 (GCC 13-64) TESTS 27 187 19251200
339830074 Redial E Sept. 22, 2025, 5:11 a.m. OK C++20 (GCC 13-64) TESTS 27 187 19251200
339823153 Botao_Xiong E Sept. 22, 2025, 3:32 a.m. OK C++20 (GCC 13-64) TESTS 27 187 19251200
339825313 cooluo E Sept. 22, 2025, 4:02 a.m. OK C++23 (GCC 14-64, msys2) TESTS 27 140 12902400
339778607 Lovely_Lyn E Sept. 21, 2025, 4:32 p.m. OK C++23 (GCC 14-64, msys2) TESTS 25 155 59084800
339793479 vikas_h E Sept. 21, 2025, 6:05 p.m. OK C++23 (GCC 14-64, msys2) TESTS 26 171 7065600
339835005 donghaocheng E Sept. 22, 2025, 6:03 a.m. OK C++23 (GCC 14-64, msys2) TESTS 27 171 10854400
339829265 Warturtle E Sept. 22, 2025, 5 a.m. OK C++23 (GCC 14-64, msys2) TESTS 27 171 10854400
339813247 MultiverseMadness E Sept. 22, 2025, 12:52 a.m. OK C++23 (GCC 14-64, msys2) TESTS 27 171 10854400
339811165 yoCandy E Sept. 21, 2025, 11:42 p.m. OK C++23 (GCC 14-64, msys2) TESTS 27 171 10854400
339825565 LouisHurtin E Sept. 22, 2025, 4:06 a.m. OK C++23 (GCC 14-64, msys2) TESTS 27 186 7065600
339803230 virinci E Sept. 21, 2025, 8:07 p.m. OK C++23 (GCC 14-64, msys2) TESTS 27 187 2252800
339813390 zhcmmm E Sept. 22, 2025, 12:55 a.m. OK C++23 (GCC 14-64, msys2) TESTS 27 187 8294400
339770700 cyclop5 E Sept. 21, 2025, 4:11 p.m. OK Go TESTS 25 749 42393600
339776804 BigTJ E Sept. 21, 2025, 4:27 p.m. OK Java 21 TESTS 25 499 51609600
339783979 MaxBuzz E Sept. 21, 2025, 4:48 p.m. OK Java 21 TESTS 25 718 41779200
339811164 Caylex E Sept. 21, 2025, 11:42 p.m. OK PyPy 3-64 TESTS 27 546 57139200
339818458 smilences E Sept. 22, 2025, 2:25 a.m. OK PyPy 3-64 TESTS 27 608 52838400
339815039 zouyu9631 E Sept. 22, 2025, 1:36 a.m. OK PyPy 3-64 TESTS 27 624 52019200
339774584 eepsilon E Sept. 21, 2025, 4:21 p.m. OK PyPy 3-64 TESTS 25 655 48537600
339818908 krism E Sept. 22, 2025, 2:32 a.m. OK PyPy 3-64 TESTS 27 796 51814400
339805895 V3k0r E Sept. 21, 2025, 8:56 p.m. OK PyPy 3-64 TESTS 27 1015 55705600
339818631 krism E Sept. 22, 2025, 2:27 a.m. OK PyPy 3-64 TESTS 27 1249 48844800
339819876 x3x3 E Sept. 22, 2025, 2:44 a.m. OK PyPy 3-64 TESTS 27 1296 56729600
339777251 pierrot E Sept. 21, 2025, 4:28 p.m. OK PyPy 3-64 TESTS 25 1483 47411200

remove filters

Back to search problems