Codeforces Round 1054 (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
2149 Codeforces Round 1054 (Div. 3) FINISHED False 8100 17594723 Sept. 25, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 27953 ) C MEX rose PROGRAMMING greedy

You are given an array (a) of length (n) and a number (k), where (0 \le k \le n). In one operation, you can choose any index (i) ((1 \le i \le n)) and set (a_i) to any integer value (x) from the range (0,n). Find the minimum number of such operations required to satisfy the condition: (\operatorname{MEX}(a))(^{\text{∗}})(=k) (^{\text{∗}})The minimum excluded (MEX) of a set of numbers (a_1,a_2,\dots,a_n) is the smallest non-negative integer (x) that does not appear among the (a_i). Each test consists of several sets of input data. The first line contains one integer (t) ((1 \le t \le 10^4)) — the number of sets of input data. The description of the sets of input data follows. The first line of each set of input data contains two integers (n) and (k) ((1 \le n \le 2 \cdot 10^5,\,\, 0 \le k \le n)) — the length of the array (a) and the required (\operatorname{MEX}(a)). The second line contains (n) integers (a_1,a_2,\dots,a_n) ((0 \le a_i \le n)) — the elements of the array (a). It is guaranteed that the sum of the values of (n) across all sets of input data does not exceed (2 \cdot 10^5). For each set of input data, output one integer — the minimum number of operations required to satisfy the condition (\operatorname{MEX}(a)=k). In the first set of input data, the array (a=0), so (\operatorname{MEX}=1). (\\) By removing zero (replacing it with any (x\in1,n)), we get (\operatorname{MEX}=0). (\\) Thus, exactly one operation is required. In the third set of input data, the array contains all the numbers (0,1,2,3,4), so (\operatorname{MEX}(a)=5) from the start. Since this matches the required (k), no changes are needed and the minimum number of operations is (0).

Tutorials

__rose

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
340511702 ArturoR2D2 C Sept. 25, 2025, 5:17 p.m. OK C++17 (GCC 7-32) TESTS 4 61 0
340505694 sounakray496 C Sept. 25, 2025, 4:48 p.m. OK C++17 (GCC 7-32) TESTS 4 61 0
340504476 Abhay72 C Sept. 25, 2025, 4:46 p.m. OK C++17 (GCC 7-32) TESTS 4 61 0
340522988 realrahin90 C Sept. 25, 2025, 6:52 p.m. OK C++17 (GCC 7-32) TESTS 10 62 0
340514909 fragzelion_72 C Sept. 25, 2025, 5:41 p.m. OK C++17 (GCC 7-32) TESTS 4 62 0
340503954 aryanrworks C Sept. 25, 2025, 4:45 p.m. OK C++17 (GCC 7-32) TESTS 4 62 0
340503327 bling_03 C Sept. 25, 2025, 4:44 p.m. OK C++17 (GCC 7-32) TESTS 4 62 0
340513992 an3791 C Sept. 25, 2025, 5:34 p.m. OK C++17 (GCC 7-32) TESTS 4 62 102400
340513727 cryptic_cook C Sept. 25, 2025, 5:32 p.m. OK C++17 (GCC 7-32) TESTS 4 62 1433600
340568196 DazaiKakashi C Sept. 26, 2025, 6:03 a.m. OK C++17 (GCC 7-32) TESTS 10 77 0
340515309 akshit269 C Sept. 25, 2025, 5:44 p.m. OK C++20 (GCC 13-64) TESTS 4 46 0
340561233 R3mix C Sept. 26, 2025, 4:52 a.m. OK C++20 (GCC 13-64) TESTS 10 61 0
340517815 IustinFrateanu C Sept. 25, 2025, 6:05 p.m. OK C++20 (GCC 13-64) TESTS 4 61 0
340517469 d__b C Sept. 25, 2025, 6:02 p.m. OK C++20 (GCC 13-64) TESTS 4 61 0
340515797 defender087 C Sept. 25, 2025, 5:49 p.m. OK C++20 (GCC 13-64) TESTS 4 61 0
340508454 ra_hulYadav669 C Sept. 25, 2025, 4:57 p.m. OK C++20 (GCC 13-64) TESTS 4 61 0
340544864 Geothermal C Sept. 26, 2025, 12:45 a.m. OK C++20 (GCC 13-64) TESTS 10 61 102400
340558426 N1664 C Sept. 26, 2025, 4:23 a.m. OK C++20 (GCC 13-64) TESTS 10 62 0
340557206 ywc_ C Sept. 26, 2025, 4:03 a.m. OK C++20 (GCC 13-64) TESTS 10 62 0
340551695 sav1209 C Sept. 26, 2025, 2:44 a.m. OK C++20 (GCC 13-64) TESTS 10 62 0
340516657 Fadhil_006 C Sept. 25, 2025, 5:56 p.m. OK C++23 (GCC 14-64, msys2) TESTS 4 46 0
340515624 yousab_moheb99 C Sept. 25, 2025, 5:47 p.m. OK C++23 (GCC 14-64, msys2) TESTS 4 46 0
340512158 hassan__3laa C Sept. 25, 2025, 5:20 p.m. OK C++23 (GCC 14-64, msys2) TESTS 4 46 0
340510386 _Balerion C Sept. 25, 2025, 5:09 p.m. OK C++23 (GCC 14-64, msys2) TESTS 4 46 0
340509078 0.3 C Sept. 25, 2025, 5:01 p.m. OK C++23 (GCC 14-64, msys2) TESTS 4 46 0
340553316 Mohammad_Shuvon C Sept. 26, 2025, 3:08 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 61 0
340512899 Pinaki38 C Sept. 25, 2025, 5:26 p.m. OK C++23 (GCC 14-64, msys2) TESTS 4 61 0
340511529 surmullet C Sept. 25, 2025, 5:16 p.m. OK C++23 (GCC 14-64, msys2) TESTS 4 61 0
340511181 TheHonouredOne21 C Sept. 25, 2025, 5:14 p.m. OK C++23 (GCC 14-64, msys2) TESTS 4 61 0
340563907 Mo_hab C Sept. 26, 2025, 5:16 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 62 0
340508099 jai314 C Sept. 25, 2025, 4:55 p.m. OK GNU C11 TESTS 4 77 716800
340518841 ZXY_001 C Sept. 25, 2025, 6:15 p.m. OK GNU C11 TESTS 4 77 1638400
340507851 jai314 C Sept. 25, 2025, 4:54 p.m. OK GNU C11 TESTS 4 93 716800
340537935 a-khushal C Sept. 25, 2025, 9:57 p.m. OK GNU C11 TESTS 10 93 921600
340503821 aksupes C Sept. 25, 2025, 4:45 p.m. OK GNU C11 TESTS 4 93 1433600
340531064 seven_stars_servers C Sept. 25, 2025, 8:23 p.m. OK GNU C11 TESTS 10 93 1638400
340529192 Alpha_Zeros C Sept. 25, 2025, 8 p.m. OK GNU C11 TESTS 10 93 1740800
340536705 shantanu_sharma.official C Sept. 25, 2025, 9:40 p.m. OK GNU C11 TESTS 10 109 819200
340556525 satwik_walker C Sept. 26, 2025, 3:54 a.m. OK GNU C11 TESTS 10 327 1638400
340522382 luckykumar232727 C Sept. 25, 2025, 6:46 p.m. OK GNU C11 TESTS 10 343 1638400
340522017 Yosa C Sept. 25, 2025, 6:43 p.m. OK Go TESTS 10 1046 7884800
340562372 Selvaragavan_C C Sept. 26, 2025, 5:01 a.m. OK Java 21 TESTS 10 234 1843200
340505097 NeydTM C Sept. 25, 2025, 4:47 p.m. OK Java 21 TESTS 4 265 307200
340520082 VolcaBit C Sept. 25, 2025, 6:25 p.m. OK Java 21 TESTS 10 296 614400
340518382 dharahas C Sept. 25, 2025, 6:10 p.m. OK Java 21 TESTS 4 296 10240000
340519433 I_AM_SPEED C Sept. 25, 2025, 6:19 p.m. OK Java 21 TESTS 10 296 12492800
340506348 Learn2SolveP C Sept. 25, 2025, 4:49 p.m. OK Java 21 TESTS 4 296 42496000
340558479 mzip C Sept. 26, 2025, 4:24 a.m. OK Java 21 TESTS 10 311 409600
340541255 mera_naam_coder C Sept. 25, 2025, 11:16 p.m. OK Java 21 TESTS 10 311 7475200
340508366 NeydTM C Sept. 25, 2025, 4:57 p.m. OK Java 21 TESTS 4 327 819200
340567804 mali.avadhut7 C Sept. 26, 2025, 5:59 a.m. OK Java 21 TESTS 10 343 7372800
340504608 abhi_theq C Sept. 25, 2025, 4:46 p.m. OK Java 8 TESTS 4 186 307200
340504258 Shipra8377 C Sept. 25, 2025, 4:46 p.m. OK Java 8 TESTS 4 202 6348800
340512821 pranavarya2005 C Sept. 25, 2025, 5:25 p.m. OK Java 8 TESTS 4 343 0
340565692 Joeljo C Sept. 26, 2025, 5:36 a.m. OK Java 8 TESTS 10 374 0
340553936 chengzijun_de_xiatian C Sept. 26, 2025, 3:17 a.m. OK Java 8 TESTS 10 374 0
340526713 abhaysolanki1712 C Sept. 25, 2025, 7:31 p.m. OK Java 8 TESTS 10 374 0
340532823 jroy.karnati C Sept. 25, 2025, 8:47 p.m. OK Java 8 TESTS 10 389 0
340519327 SAI_GANGADHAR_0 C Sept. 25, 2025, 6:19 p.m. OK Java 8 TESTS 10 405 0
340506543 HarshniKannan100 C Sept. 25, 2025, 4:49 p.m. OK Java 8 TESTS 4 405 0
340511664 YZH_1014 C Sept. 25, 2025, 5:17 p.m. OK Java 8 TESTS 4 421 0
340515005 andrewliu10523 C Sept. 25, 2025, 5:42 p.m. OK PyPy 3 TESTS 4 218 16486400
340545108 Ramine001 C Sept. 26, 2025, 12:50 a.m. OK PyPy 3 TESTS 10 327 14131200
340504210 realGrape C Sept. 25, 2025, 4:46 p.m. OK PyPy 3 TESTS 4 343 14745600
340503817 shubh_234 C Sept. 25, 2025, 4:45 p.m. OK PyPy 3 TESTS 4 359 18124800
340561711 Argonised C Sept. 26, 2025, 4:55 a.m. OK PyPy 3 TESTS 10 1031 17612800
340548876 IcyGirl C Sept. 26, 2025, 2 a.m. OK PyPy 3-64 TESTS 10 140 27545600
340505005 VSS307614_MShawaiz C Sept. 25, 2025, 4:47 p.m. OK PyPy 3-64 TESTS 4 155 20582400
340519821 ashashank3672 C Sept. 25, 2025, 6:23 p.m. OK PyPy 3-64 TESTS 10 155 22937600
340523994 Esti C Sept. 25, 2025, 7:02 p.m. OK PyPy 3-64 TESTS 10 155 26828800
340538004 monocrap C Sept. 25, 2025, 9:58 p.m. OK PyPy 3-64 TESTS 10 156 22937600
340546075 Robin_islam C Sept. 26, 2025, 1:09 a.m. OK PyPy 3-64 TESTS 10 171 18329600
340508527 j0osman C Sept. 25, 2025, 4:58 p.m. OK PyPy 3-64 TESTS 4 171 23859200
340508683 Sergey18 C Sept. 25, 2025, 4:59 p.m. OK PyPy 3-64 TESTS 4 171 25600000
340534629 HelloGoodbye C Sept. 25, 2025, 9:15 p.m. OK PyPy 3-64 TESTS 10 171 27033600
340511092 Robin_islam C Sept. 25, 2025, 5:13 p.m. OK PyPy 3-64 TESTS 4 187 23961600
340508808 Jaswini_Gali17 C Sept. 25, 2025, 4:59 p.m. OK Python 3 TESTS 4 139 20992000
340534873 Garv_12 C Sept. 25, 2025, 9:19 p.m. OK Python 3 TESTS 10 140 22630400
340532993 Jyotier C Sept. 25, 2025, 8:50 p.m. OK Python 3 TESTS 10 140 22630400
340504614 Giang24 C Sept. 25, 2025, 4:46 p.m. OK Python 3 TESTS 4 140 22630400
340506398 dakshagarwaliitd C Sept. 25, 2025, 4:49 p.m. OK Python 3 TESTS 4 155 20889600
340504475 Adambuf C Sept. 25, 2025, 4:46 p.m. OK Python 3 TESTS 4 155 22528000
340504447 2310030101 C Sept. 25, 2025, 4:46 p.m. OK Python 3 TESTS 4 155 22528000
340521408 shivamsinhagaya2020 C Sept. 25, 2025, 6:37 p.m. OK Python 3 TESTS 10 156 22016000
340534955 Garv_12 C Sept. 25, 2025, 9:20 p.m. OK Python 3 TESTS 10 156 23654400
340512834 SnakeThug C Sept. 25, 2025, 5:25 p.m. OK Python 3 TESTS 4 171 20992000
340554461 0x81 C Sept. 26, 2025, 3:24 a.m. OK Rust 2024 TESTS 10 46 1126400

remove filters

Back to search problems