Codeforces Round 1047 (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
2137 Codeforces Round 1047 (Div. 3) FINISHED False 8100 19149923 Sept. 7, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 10096 ) E Mexification PROGRAMMING implementation math

You are given an array (a) of size (n) and an integer (k). You do the following procedure (k) times: For each element (a_i), you set (a_i) to (\operatorname{mex})(^{\text{∗}})((a_1,a_2,\ldots,a_{i-1},a_{i+1},a_{i+2}, \ldots,a_n)). In other words, you set (a_i) to the (\operatorname{mex}) of all other elements in the array. This is done for all elements in the array at the same time. Please find the sum of elements in the array after all (k) operations. (^{\text{∗}})The minimum excluded (MEX) of a collection of integers (d_1, d_2, \ldots, d_k) is defined as the smallest non-negative integer (x) which does not occur in the collection (d). 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 contains two integers (n) and (k) ((2 \leq n \leq 2\cdot 10^5, 1 \leq k \leq 10^9)) – the number of elements in (a) and the number of operations done. The second line contains (n) integers (a_1,a_2,\ldots,a_n) ((0 \leq a_i \leq n)). It is guaranteed that the sum of (n) over all test cases does not exceed (2\cdot 10^5). For each test case, output the sum of elements after all (k) operations on a new line. In the first test case, we performed the operation on the array (0,2,1) three times. Let's compute the result after the first time: The first element becomes (\operatorname{MEX}(2,1)=0) The second element becomes (\operatorname{MEX}(0,1)=2) The third element becomes (\operatorname{MEX}(0,2)=1) So, after the first operation, (0,2,1) becomes (0,2,1) again. It can be shown that the array will not change no matter how many times we perform the operation, so the final array after three operations is still (0,2,1). The sum is (0+2+1=3). In the third test case, the array becomes (2,2,2,2).

Tutorials

Codeforces Round 1047 (Div. 3) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
337472529 m1_k3 E Sept. 7, 2025, 8:46 p.m. OK C# 13 TESTS 13 124 2150400
337472444 m1_k3 E Sept. 7, 2025, 8:45 p.m. OK C# 13 TESTS 13 124 3072000
337500104 Puzzle_ninja E Sept. 8, 2025, 5:57 a.m. OK C++17 (GCC 7-32) TESTS 13 77 102400
337459052 chslnikl E Sept. 7, 2025, 6:13 p.m. OK C++17 (GCC 7-32) TESTS 13 78 0
337475680 EndMyMisery E Sept. 7, 2025, 9:46 p.m. OK C++17 (GCC 7-32) TESTS 13 78 819200
337496705 surya_majhi E Sept. 8, 2025, 5:12 a.m. OK C++17 (GCC 7-32) TESTS 13 78 3276800
337495145 VKTnT18 E Sept. 8, 2025, 4:49 a.m. OK C++17 (GCC 7-32) TESTS 13 92 0
337462630 michaelyql E Sept. 7, 2025, 6:47 p.m. OK C++17 (GCC 7-32) TESTS 13 92 0
337463072 sonali_cant_code E Sept. 7, 2025, 6:51 p.m. OK C++17 (GCC 7-32) TESTS 13 92 204800
337500164 aanamishra2407 E Sept. 8, 2025, 5:57 a.m. OK C++17 (GCC 7-32) TESTS 13 93 0
337499980 alphaegg E Sept. 8, 2025, 5:55 a.m. OK C++17 (GCC 7-32) TESTS 13 93 0
337497530 Yashwanth_RJ E Sept. 8, 2025, 5:22 a.m. OK C++17 (GCC 7-32) TESTS 13 93 0
337483368 NNCS E Sept. 8, 2025, 1:12 a.m. OK C++20 (GCC 13-64) TESTS 13 62 1638400
337495428 Alail_996 E Sept. 8, 2025, 4:53 a.m. OK C++20 (GCC 13-64) TESTS 13 77 0
337493513 Osama_Ashraf01 E Sept. 8, 2025, 4:21 a.m. OK C++20 (GCC 13-64) TESTS 13 77 0
337492784 Day_Day_Happy E Sept. 8, 2025, 4:07 a.m. OK C++20 (GCC 13-64) TESTS 13 77 0
337492528 ayhamzaidd E Sept. 8, 2025, 4:01 a.m. OK C++20 (GCC 13-64) TESTS 13 77 0
337482104 LiKeROSE E Sept. 8, 2025, 12:40 a.m. OK C++20 (GCC 13-64) TESTS 13 77 0
337482019 LiKeROSE E Sept. 8, 2025, 12:38 a.m. OK C++20 (GCC 13-64) TESTS 13 77 0
337478770 robanjov E Sept. 7, 2025, 11:03 p.m. OK C++20 (GCC 13-64) TESTS 13 77 0
337471724 ritikkumar9314 E Sept. 7, 2025, 8:33 p.m. OK C++20 (GCC 13-64) TESTS 13 77 0
337466257 Owv E Sept. 7, 2025, 7:27 p.m. OK C++20 (GCC 13-64) TESTS 13 77 0
337452652 424479543 E Sept. 7, 2025, 5:27 p.m. OK C++23 (GCC 14-64, msys2) TESTS 13 61 921600
337499627 sssatty E Sept. 8, 2025, 5:51 a.m. OK C++23 (GCC 14-64, msys2) TESTS 13 77 0
337497435 ShadowSPG E Sept. 8, 2025, 5:21 a.m. OK C++23 (GCC 14-64, msys2) TESTS 13 77 0
337495208 Malhar_17 E Sept. 8, 2025, 4:50 a.m. OK C++23 (GCC 14-64, msys2) TESTS 13 77 0
337493228 Liuguang_Ji E Sept. 8, 2025, 4:16 a.m. OK C++23 (GCC 14-64, msys2) TESTS 13 77 0
337492158 HarshitChowdhury E Sept. 8, 2025, 3:55 a.m. OK C++23 (GCC 14-64, msys2) TESTS 13 77 0
337491845 _val_ E Sept. 8, 2025, 3:49 a.m. OK C++23 (GCC 14-64, msys2) TESTS 13 77 0
337485821 AhmedReda E Sept. 8, 2025, 2:10 a.m. OK C++23 (GCC 14-64, msys2) TESTS 13 77 0
337485449 ProfaSIO E Sept. 8, 2025, 2:01 a.m. OK C++23 (GCC 14-64, msys2) TESTS 13 77 0
337482410 Aspirebugs E Sept. 8, 2025, 12:47 a.m. OK C++23 (GCC 14-64, msys2) TESTS 13 77 0
337459545 mlinear E Sept. 7, 2025, 6:18 p.m. OK Java 21 TESTS 13 265 1228800
337476494 BOB_005 E Sept. 7, 2025, 10 p.m. OK Java 21 TESTS 13 296 819200
337479510 ishanmandal5 E Sept. 7, 2025, 11:25 p.m. OK Java 21 TESTS 13 312 1536000
337470997 harsh__bhatter E Sept. 7, 2025, 8:23 p.m. OK Java 21 TESTS 13 406 716800
337472644 Soumarya_Pal E Sept. 7, 2025, 8:49 p.m. OK Java 21 TESTS 13 452 26316800
337458127 Freankin E Sept. 7, 2025, 6:06 p.m. OK Java 21 TESTS 13 671 24576000
337452103 rizzzii E Sept. 7, 2025, 5:23 p.m. OK Java 21 TESTS 13 686 25190400
337445699 NobelPrizeIsMine E Sept. 7, 2025, 4:51 p.m. OK Java 21 TESTS 13 765 6246400
337465651 Goutham_808 E Sept. 7, 2025, 7:20 p.m. OK Java 21 TESTS 13 858 25804800
337452711 Infinityy08 E Sept. 7, 2025, 5:27 p.m. OK Java 21 TESTS 13 984 18739200
337446226 Eslam_Ahmed E Sept. 7, 2025, 4:53 p.m. OK Java 8 TESTS 13 187 2662400
337493825 suntansoker E Sept. 8, 2025, 4:27 a.m. OK Java 8 TESTS 13 311 12288000
337494527 suntansoker E Sept. 8, 2025, 4:39 a.m. OK Java 8 TESTS 13 343 12800000
337500664 kasiru_69 E Sept. 8, 2025, 6:04 a.m. OK Java 8 TESTS 13 390 25190400
337499236 KrishnaDuby E Sept. 8, 2025, 5:46 a.m. OK Java 8 TESTS 13 406 0
337471059 Shashwata_32 E Sept. 7, 2025, 8:24 p.m. OK Java 8 TESTS 13 421 51097600
337452252 yashbansal99 E Sept. 7, 2025, 5:24 p.m. OK Java 8 TESTS 13 467 0
337460670 QuadD4rv1n7 E Sept. 7, 2025, 6:28 p.m. OK Kotlin 2.2 TESTS 13 218 1433600
337473537 quantiset E Sept. 7, 2025, 9:03 p.m. OK PyPy 3 TESTS 13 358 12800000
337478986 gopikrishna9968 E Sept. 7, 2025, 11:09 p.m. OK PyPy 3 TESTS 13 390 28160000
337451399 Manvith_reddy E Sept. 7, 2025, 5:19 p.m. OK PyPy 3 TESTS 13 640 23552000
337452313 pipylon E Sept. 7, 2025, 5:24 p.m. OK PyPy 3 TESTS 13 702 47411200
337476590 gardengnome E Sept. 7, 2025, 10:02 p.m. OK PyPy 3-64 TESTS 13 171 21401600
337461539 gardengnome E Sept. 7, 2025, 6:36 p.m. OK PyPy 3-64 TESTS 13 171 28876800
337482621 jvatsal0709 E Sept. 8, 2025, 12:53 a.m. OK PyPy 3-64 TESTS 13 186 26316800
337482680 jvatsal0709 E Sept. 8, 2025, 12:54 a.m. OK PyPy 3-64 TESTS 13 187 26521600
337472102 bomaring E Sept. 7, 2025, 8:39 p.m. OK PyPy 3-64 TESTS 13 202 20787200
337482247 udayan8 E Sept. 8, 2025, 12:44 a.m. OK PyPy 3-64 TESTS 13 203 25600000
337447554 deepsr2003 E Sept. 7, 2025, 4:58 p.m. OK PyPy 3-64 TESTS 13 218 19148800
337500102 ChickenTamer E Sept. 8, 2025, 5:57 a.m. OK PyPy 3-64 TESTS 13 218 28672000
337448153 LogicErr E Sept. 7, 2025, 5:01 p.m. OK PyPy 3-64 TESTS 13 234 30310400
337494006 Prophet05 E Sept. 8, 2025, 4:30 a.m. OK PyPy 3-64 TESTS 13 249 20582400
337466855 aziz10 E Sept. 7, 2025, 7:34 p.m. OK Python 3 TESTS 13 218 23449600
337471641 ranveer_sahu E Sept. 7, 2025, 8:32 p.m. OK Python 3 TESTS 13 249 23347200
337485055 BWHM E Sept. 8, 2025, 1:52 a.m. OK Python 3 TESTS 13 265 26419200
337485431 Pranav125 E Sept. 8, 2025, 2 a.m. OK Python 3 TESTS 13 296 26419200
337462654 coderrg21 E Sept. 7, 2025, 6:47 p.m. OK Python 3 TESTS 13 312 26726400
337466437 DT4V E Sept. 7, 2025, 7:29 p.m. OK Python 3 TESTS 13 327 42291200
337448570 VioletVal E Sept. 7, 2025, 5:03 p.m. OK Python 3 TESTS 13 328 21401600
337451314 arya_jain E Sept. 7, 2025, 5:18 p.m. OK Python 3 TESTS 13 358 22220800
337470824 jsbiwnkdjvw E Sept. 7, 2025, 8:20 p.m. OK Python 3 TESTS 13 483 47513600
337466553 Dharunpathi E Sept. 7, 2025, 7:30 p.m. OK Python 3 TESTS 13 484 34406400
337497548 InO4 E Sept. 8, 2025, 5:23 a.m. OK Rust 2024 TESTS 13 62 10444800
337452941 ardririy E Sept. 7, 2025, 5:29 p.m. OK Rust 2024 TESTS 13 109 6963200

remove filters

Back to search problems