Codeforces Round 1061 (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
2156 Codeforces Round 1061 (Div. 2) FINISHED False 7200 15607485 Oct. 24, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 12221 ) C Maximum GCD on Whiteboard PROGRAMMING greedy math number theory

You are given an integer (k) and (n) positive integers (a_1, a_2, \ldots, a_n) written on a whiteboard, where (1\le a_i\le \boldsymbol{n}). You may perform the following operations: Erase : Choose an integer from the whiteboard and erase it. This operation can be performed at most (k) times. Split : Choose an integer (x\ge 3) from the whiteboard. Split it into three positive integers (x_1), (x_2), and (x_3) such that (x_1 + x_2 + x_3 = x), and (1\le x_1\le x_2\le x_3). Then, erase (x) from the whiteboard and write two new integers (x_1) and (x_3) on the whiteboard. Note that (x_2) is discarded and not written on the whiteboard. This operation may be performed any number of times. The beauty of a collection of integers (b) is defined as the greatest common divisor of all the elements in (b). Formally, it is the largest integer (d) such that (d) divides (x) for every (x) that is an element of (b). Your task is to determine the maximum possible beauty of the integers on the whiteboard after performing at most (k) Erase operations and any number of Split operations. 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 two integers (n) and (k) ((1\le n \le 2 \cdot 10^5), (0 \le k \le n - 1)) — the number of integers on the whiteboard, and the maximum number of Erase operations allowed. The second line of each test case contains (n) integers (a_1, a_2, \ldots, a_n) ((1 \le a_i \le \boldsymbol{n})) — the integers initially written on the whiteboard. It is guaranteed that the sum of (n) over all test cases does not exceed (2 \cdot 10^5). For each test case, output a single integer representing the maximum beauty of the elements written on the whiteboard after performing the operations.

Tutorials

Codeforces Round 1061 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
345639806 ksandr1v C Oct. 24, 2025, 6:24 p.m. OK C# 13 TESTS 20 140 7372800
345685744 AnCs-Lan C Oct. 25, 2025, 5:18 a.m. OK C++17 (GCC 7-32) TESTS 20 77 0
345684541 Luffy-san C Oct. 25, 2025, 5:04 a.m. OK C++17 (GCC 7-32) TESTS 20 78 0
345672642 WHGG C Oct. 25, 2025, 2:09 a.m. OK C++17 (GCC 7-32) TESTS 20 78 2457600
345684709 AlindTyagi C Oct. 25, 2025, 5:06 a.m. OK C++17 (GCC 7-32) TESTS 20 92 0
345677115 _FAUST_ C Oct. 25, 2025, 3:23 a.m. OK C++17 (GCC 7-32) TESTS 20 92 0
345671387 devkotecha C Oct. 25, 2025, 1:42 a.m. OK C++17 (GCC 7-32) TESTS 20 92 0
345690724 mamba_dj C Oct. 25, 2025, 6:03 a.m. OK C++17 (GCC 7-32) TESTS 20 93 0
345690593 pushkardev123 C Oct. 25, 2025, 6:01 a.m. OK C++17 (GCC 7-32) TESTS 20 93 0
345687959 EigenEdge C Oct. 25, 2025, 5:39 a.m. OK C++17 (GCC 7-32) TESTS 20 93 0
345685008 nikiitsme C Oct. 25, 2025, 5:09 a.m. OK C++17 (GCC 7-32) TESTS 20 93 0
345668336 Adithya-02 C Oct. 25, 2025, 12:28 a.m. OK C++20 (GCC 13-64) TESTS 20 77 0
345667550 christopherbitti9 C Oct. 25, 2025, 12:02 a.m. OK C++20 (GCC 13-64) TESTS 20 77 0
345662813 banziya C Oct. 24, 2025, 10 p.m. OK C++20 (GCC 13-64) TESTS 20 77 0
345660440 mzxqltyogb C Oct. 24, 2025, 9:19 p.m. OK C++20 (GCC 13-64) TESTS 20 77 0
345680525 xiaomo1001 C Oct. 25, 2025, 4:13 a.m. OK C++20 (GCC 13-64) TESTS 20 77 204800
345686846 binglengmo C Oct. 25, 2025, 5:29 a.m. OK C++20 (GCC 13-64) TESTS 20 77 307200
345682984 HissekiWriting C Oct. 25, 2025, 4:46 a.m. OK C++20 (GCC 13-64) TESTS 20 77 921600
345671938 fox_arrow__ C Oct. 25, 2025, 1:54 a.m. OK C++20 (GCC 13-64) TESTS 20 77 921600
345683040 _Harry__potter_ C Oct. 25, 2025, 4:46 a.m. OK C++20 (GCC 13-64) TESTS 20 77 1024000
345681010 _KingBob_ C Oct. 25, 2025, 4:20 a.m. OK C++20 (GCC 13-64) TESTS 20 77 3379200
345683251 dkdk C Oct. 25, 2025, 4:49 a.m. OK C++23 (GCC 14-64, msys2) TESTS 20 62 4300800
345690384 Suni9977 C Oct. 25, 2025, 6 a.m. OK C++23 (GCC 14-64, msys2) TESTS 20 77 0
345684799 SaltMangoTree C Oct. 25, 2025, 5:07 a.m. OK C++23 (GCC 14-64, msys2) TESTS 20 77 0
345681652 Dynamic_Pigeon C Oct. 25, 2025, 4:29 a.m. OK C++23 (GCC 14-64, msys2) TESTS 20 77 0
345675884 you-jin-plus C Oct. 25, 2025, 3:05 a.m. OK C++23 (GCC 14-64, msys2) TESTS 20 77 0
345668290 Champ28 C Oct. 25, 2025, 12:27 a.m. OK C++23 (GCC 14-64, msys2) TESTS 20 77 0
345690293 Lianko C Oct. 25, 2025, 5:59 a.m. OK C++23 (GCC 14-64, msys2) TESTS 20 77 102400
345677828 _Dragneel C Oct. 25, 2025, 3:33 a.m. OK C++23 (GCC 14-64, msys2) TESTS 20 77 102400
345677695 PhamHaiThach C Oct. 25, 2025, 3:31 a.m. OK C++23 (GCC 14-64, msys2) TESTS 20 77 102400
345683080 P_Shuks C Oct. 25, 2025, 4:47 a.m. OK C++23 (GCC 14-64, msys2) TESTS 20 77 1024000
345656417 NenadDapic C Oct. 24, 2025, 8:30 p.m. OK FPC TESTS 20 109 1638400
345647916 ruban C Oct. 24, 2025, 7:14 p.m. OK FPC TESTS 20 109 91750400
345685548 Shivvelnad C Oct. 25, 2025, 5:15 a.m. OK GNU C11 TESTS 20 139 2457600
345615206 atharvahon_109 C Oct. 24, 2025, 4:29 p.m. OK Go TESTS 20 93 10956800
345656823 fishy15 C Oct. 24, 2025, 8:34 p.m. OK Haskell TESTS 20 124 6246400
345613830 nabina1395 C Oct. 24, 2025, 4:27 p.m. OK Java 21 TESTS 20 296 716800
345664669 sagbis C Oct. 24, 2025, 10:36 p.m. OK Java 21 TESTS 20 312 1331200
345647782 BiggestFish06 C Oct. 24, 2025, 7:13 p.m. OK Java 21 TESTS 20 312 1331200
345664567 yassjd199 C Oct. 24, 2025, 10:34 p.m. OK Java 21 TESTS 20 343 921600
345614542 sohxm2k C Oct. 24, 2025, 4:28 p.m. OK Java 21 TESTS 20 343 2252800
345635415 WrongAnswerOnTestCase2 C Oct. 24, 2025, 6:06 p.m. OK Java 21 TESTS 20 343 12083200
345623151 Burhan_Akkus C Oct. 24, 2025, 5:29 p.m. OK Java 21 TESTS 20 421 716800
345625213 Mazen_Alaa C Oct. 24, 2025, 5:37 p.m. OK Java 21 TESTS 20 437 16793600
345643315 tekka_ity C Oct. 24, 2025, 6:43 p.m. OK Java 21 TESTS 20 484 19046400
345688796 shyamPrajapat C Oct. 25, 2025, 5:47 a.m. OK Java 21 TESTS 20 577 1331200
345680917 ycnetsisnoc C Oct. 25, 2025, 4:18 a.m. OK Java 8 TESTS 20 187 0
345685388 testtest111ksjfrdvn C Oct. 25, 2025, 5:13 a.m. OK Java 8 TESTS 20 203 2764800
345685147 testtest111ksjfrdvn C Oct. 25, 2025, 5:11 a.m. OK Java 8 TESTS 20 218 2969600
345666562 alibaba C Oct. 24, 2025, 11:29 p.m. OK Java 8 TESTS 20 374 12288000
345630043 devsac12 C Oct. 24, 2025, 5:59 p.m. OK Java 8 TESTS 20 436 0
345688258 prime29 C Oct. 25, 2025, 5:42 a.m. OK Java 8 TESTS 20 468 24371200
345627425 KuldeepChauhan C Oct. 24, 2025, 5:48 p.m. OK Java 8 TESTS 20 499 0
345677560 kevin_0911 C Oct. 25, 2025, 3:29 a.m. OK Java 8 TESTS 20 499 14131200
345626525 NavneetKumar123 C Oct. 24, 2025, 5:44 p.m. OK Java 8 TESTS 20 546 0
345628951 xmjlove C Oct. 24, 2025, 5:54 p.m. OK Java 8 TESTS 20 624 12083200
345645720 mikejohansson69 C Oct. 24, 2025, 6:58 p.m. OK PyPy 3 TESTS 20 327 16179200
345690766 gawkmaster069 C Oct. 25, 2025, 6:03 a.m. OK PyPy 3-64 TESTS 20 155 25804800
345678642 seifkh03 C Oct. 25, 2025, 3:46 a.m. OK PyPy 3-64 TESTS 20 171 24576000
345691234 LMeyling C Oct. 25, 2025, 6:07 a.m. OK PyPy 3-64 TESTS 20 171 25292800
345679813 Mottchan123 C Oct. 25, 2025, 4:02 a.m. OK PyPy 3-64 TESTS 20 187 25497600
345656490 srinadh777 C Oct. 24, 2025, 8:31 p.m. OK PyPy 3-64 TESTS 20 187 25600000
345672147 hana_yuki C Oct. 25, 2025, 1:59 a.m. OK PyPy 3-64 TESTS 20 187 27340800
345664533 cf1201 C Oct. 24, 2025, 10:33 p.m. OK PyPy 3-64 TESTS 20 187 33996800
345683511 Little_Sheep_Yawn C Oct. 25, 2025, 4:52 a.m. OK PyPy 3-64 TESTS 20 202 26931200
345663194 explainer C Oct. 24, 2025, 10:07 p.m. OK PyPy 3-64 TESTS 20 202 29388800
345626887 Hyder1102 C Oct. 24, 2025, 5:45 p.m. OK PyPy 3-64 TESTS 20 202 29798400
345683777 surendravarma780 C Oct. 25, 2025, 4:55 a.m. OK Python 3 TESTS 20 202 23142400
345627909 introuvable C Oct. 24, 2025, 5:50 p.m. OK Python 3 TESTS 20 218 22630400
345615877 FerryMan27 C Oct. 24, 2025, 4:30 p.m. OK Python 3 TESTS 20 218 23449600
345665875 Soultaker C Oct. 24, 2025, 11:10 p.m. OK Python 3 TESTS 20 218 23961600
345615638 koushcodes C Oct. 24, 2025, 4:30 p.m. OK Python 3 TESTS 20 233 26214400
345614984 tharanadithya C Oct. 24, 2025, 4:29 p.m. OK Python 3 TESTS 20 358 22937600
345646337 nba_yeabsira C Oct. 24, 2025, 7:02 p.m. OK Python 3 TESTS 20 405 29184000
345672058 komatiminnu6 C Oct. 25, 2025, 1:57 a.m. OK Python 3 TESTS 20 437 30105600
345612740 Sandesh_7 C Oct. 24, 2025, 4:25 p.m. OK Python 3 TESTS 20 468 32563200
345623971 mdisharaf C Oct. 24, 2025, 5:32 p.m. OK Python 3 TESTS 20 499 23449600
345660381 DreadedHippy C Oct. 24, 2025, 9:18 p.m. OK Rust 2021 TESTS 20 77 819200

remove filters

Back to search problems