Codeforces Round 1060 (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
2154 Codeforces Round 1060 (Div. 2) FINISHED False 7200 15521123 Oct. 19, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 13422 ) C1 No Cost Too Great (Easy Version) PROGRAMMING greedy implementation math number theory

This is the easy version of the problem. The difference between the versions is that in this version, (b_i = 1) for all (i) ((1 \le i \le n)). You can hack only if you solved all versions of this problem. You find yourself with two arrays of positive integers (a) and (b), both of length (n). You will perform the following operation any number of times (possibly none): select an integer (i) ((1 \le i \le n)) and increase (a_i) by (1). This has a cost of (b_i). Determine the minimum total cost to make it so that there exists two integers (i, j) where (1 \le i < j \le n) and (\gcd(a_i, a_j))(^{\text{∗}})(> 1). (^{\text{∗}})(\gcd(x, y)) denotes the greatest common divisor (GCD) of integers (x) and (y). 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 an integer (n) ((2 \le n \le 2 \cdot 10^5)) — the length of the array (a). The second line of each test case contains (n) integers (a_1,a_2,\ldots,a_n) ((1 \le a_i \le 2 \cdot 10^5)). The third line of each test case contains (n) integers (b_1,b_2,\ldots,b_n) ((\color{red}{b_i = 1})). The sum of (n) across all test cases does not exceed (2 \cdot 10^5). For each testcase, output the minimum cost. In the first test case, we can do the following: (\color{red}1, 1 \xrightarrow{x = 1} 2, \color{red}1 \xrightarrow{x = 2} 2, 2). Now (\gcd(a_1, a_2) = \gcd(2, 2) = 2) and so (\gcd(a_1, a_2) > 1). It can be proven that this is the minimum cost required. In the second test case, it is already true that (\gcd(a_1, a_2) = 4) and so (\gcd(a_1, a_2) > 1). So no operations are required.

Tutorials

Codeforces Round 1060 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
344744885 rasadli C1 Oct. 19, 2025, 4:33 p.m. OK C# 13 TESTS 21 139 3788800
344779224 ksandr1v C1 Oct. 19, 2025, 9:14 p.m. OK C# 13 TESTS 22 1514 13414400
344779106 ksandr1v C1 Oct. 19, 2025, 9:12 p.m. OK C# 13 TESTS 22 1546 13414400
344756789 sniper97 C1 Oct. 19, 2025, 6:02 p.m. OK C++17 (GCC 7-32) TESTS 21 155 819200
344786953 javvy C1 Oct. 19, 2025, 11:59 p.m. OK C++17 (GCC 7-32) TESTS 22 156 1638400
344758903 akarsh0904 C1 Oct. 19, 2025, 6:14 p.m. OK C++17 (GCC 7-32) TESTS 22 156 2764800
344789884 gurjar_sahab C1 Oct. 20, 2025, 1:07 a.m. OK C++17 (GCC 7-32) TESTS 22 187 1638400
344753279 MasterOfTrades C1 Oct. 19, 2025, 5:44 p.m. OK C++17 (GCC 7-32) TESTS 21 187 2662400
344785384 _AK03 C1 Oct. 19, 2025, 11:14 p.m. OK C++17 (GCC 7-32) TESTS 22 187 7065600
344763652 rrd_29 C1 Oct. 19, 2025, 6:43 p.m. OK C++17 (GCC 7-32) TESTS 22 202 0
344768986 srv_surya C1 Oct. 19, 2025, 7:23 p.m. OK C++17 (GCC 7-32) TESTS 22 202 819200
344752186 cyu17 C1 Oct. 19, 2025, 5:39 p.m. OK C++17 (GCC 7-32) TESTS 21 202 819200
344745841 THEzsc C1 Oct. 19, 2025, 4:34 p.m. OK C++17 (GCC 7-32) TESTS 21 202 1331200
344787193 hzjhzjhzj C1 Oct. 20, 2025, 12:06 a.m. OK C++20 (GCC 13-64) TESTS 22 124 5017600
344745115 IsHaNt_SiNgH C1 Oct. 19, 2025, 4:34 p.m. OK C++20 (GCC 13-64) TESTS 21 140 2764800
344759569 Denislav_Manev C1 Oct. 19, 2025, 6:18 p.m. OK C++20 (GCC 13-64) TESTS 22 140 3276800
344751638 Mtaylor C1 Oct. 19, 2025, 5:37 p.m. OK C++20 (GCC 13-64) TESTS 21 140 3891200
344760345 Sayeed_Mahdi C1 Oct. 19, 2025, 6:23 p.m. OK C++20 (GCC 13-64) TESTS 22 155 3276800
344760752 jay_1410 C1 Oct. 19, 2025, 6:25 p.m. OK C++20 (GCC 13-64) TESTS 22 156 102400
344800741 sllh_dog C1 Oct. 20, 2025, 3:57 a.m. OK C++20 (GCC 13-64) TESTS 23 156 5836800
344788838 lijunze12 C1 Oct. 20, 2025, 12:45 a.m. OK C++20 (GCC 13-64) TESTS 22 156 6860800
344763788 TTTTTTKL C1 Oct. 19, 2025, 6:44 p.m. OK C++20 (GCC 13-64) TESTS 22 171 819200
344788721 Jaylen C1 Oct. 20, 2025, 12:42 a.m. OK C++20 (GCC 13-64) TESTS 22 171 1228800
344779829 logonax C1 Oct. 19, 2025, 9:24 p.m. OK C++23 (GCC 14-64, msys2) TESTS 22 124 204800
344789415 _bro_ C1 Oct. 20, 2025, 12:57 a.m. OK C++23 (GCC 14-64, msys2) TESTS 22 124 3686400
344793293 Treow C1 Oct. 20, 2025, 2:10 a.m. OK C++23 (GCC 14-64, msys2) TESTS 22 140 0
344771476 jiangly C1 Oct. 19, 2025, 7:45 p.m. OK C++23 (GCC 14-64, msys2) TESTS 22 140 204800
344789077 sccccc C1 Oct. 20, 2025, 12:50 a.m. OK C++23 (GCC 14-64, msys2) TESTS 22 140 4812800
344794315 yuyuan567 C1 Oct. 20, 2025, 2:26 a.m. OK C++23 (GCC 14-64, msys2) TESTS 22 140 11468800
344756563 Satoru C1 Oct. 19, 2025, 6:01 p.m. OK C++23 (GCC 14-64, msys2) TESTS 21 155 0
344794575 Rebobtg C1 Oct. 20, 2025, 2:30 a.m. OK C++23 (GCC 14-64, msys2) TESTS 22 155 819200
344754977 abdulrhman.dev C1 Oct. 19, 2025, 5:53 p.m. OK C++23 (GCC 14-64, msys2) TESTS 21 155 819200
344797753 EE23B179_CP C1 Oct. 20, 2025, 3:16 a.m. OK C++23 (GCC 14-64, msys2) TESTS 23 155 1024000
344764664 NenadDapic C1 Oct. 19, 2025, 6:50 p.m. OK FPC TESTS 22 265 13516800
344767168 NenadDapic C1 Oct. 19, 2025, 7:09 p.m. OK FPC TESTS 22 421 24371200
344804603 Andrew_G6 C1 Oct. 20, 2025, 4:49 a.m. OK GNU C11 TESTS 24 515 6656000
344773305 Andrew_G6 C1 Oct. 19, 2025, 8:02 p.m. OK GNU C11 TESTS 22 546 6451200
344776246 Andrew_G6 C1 Oct. 19, 2025, 8:36 p.m. OK GNU C11 TESTS 22 577 6451200
344774337 Andrew_G6 C1 Oct. 19, 2025, 8:13 p.m. OK GNU C11 TESTS 22 842 40140800
344745929 NotnaKO C1 Oct. 19, 2025, 4:34 p.m. OK Go TESTS 21 265 12595200
344757199 nobody05 C1 Oct. 19, 2025, 6:05 p.m. OK Go TESTS 21 703 20172800
344794441 uffhottie C1 Oct. 20, 2025, 2:28 a.m. OK Go TESTS 22 1078 11366400
344754765 AAcup C1 Oct. 19, 2025, 5:52 p.m. OK Go TESTS 21 1093 20582400
344759276 chethan_coding C1 Oct. 19, 2025, 6:16 p.m. OK Go TESTS 22 1108 5324800
344750915 dzhabrailovhuseyn C1 Oct. 19, 2025, 5:33 p.m. OK Go TESTS 21 1843 5120000
344751077 NpHardcore_05 C1 Oct. 19, 2025, 5:34 p.m. OK Java 21 TESTS 21 358 1433600
344786402 ysahu C1 Oct. 19, 2025, 11:42 p.m. OK Java 21 TESTS 22 421 21196800
344756026 nabina1395 C1 Oct. 19, 2025, 5:58 p.m. OK Java 21 TESTS 21 452 614400
344754882 lscratchm C1 Oct. 19, 2025, 5:53 p.m. OK Java 21 TESTS 21 452 1433600
344799038 GuLLu05 C1 Oct. 20, 2025, 3:33 a.m. OK Java 21 TESTS 23 483 1843200
344766160 cstemp C1 Oct. 19, 2025, 7:01 p.m. OK Java 21 TESTS 22 483 2867200
344751585 ramitgangwar C1 Oct. 19, 2025, 5:37 p.m. OK Java 21 TESTS 21 484 1228800
344800289 iujjwalrai C1 Oct. 20, 2025, 3:50 a.m. OK Java 21 TESTS 23 625 2355200
344750327 owner_of_world C1 Oct. 19, 2025, 5:31 p.m. OK Java 21 TESTS 21 687 819200
344807616 ryju C1 Oct. 20, 2025, 5:22 a.m. OK Java 21 TESTS 24 702 1843200
344751933 Eslam_Ahmed C1 Oct. 19, 2025, 5:38 p.m. OK Java 8 TESTS 21 374 5222400
344797407 suntansoker C1 Oct. 20, 2025, 3:11 a.m. OK Java 8 TESTS 23 390 3891200
344808303 tejas_5 C1 Oct. 20, 2025, 5:29 a.m. OK Java 8 TESTS 24 483 36864000
344812451 wanderer1509 C1 Oct. 20, 2025, 6:08 a.m. OK Java 8 TESTS 24 671 0
344806943 xmjlove C1 Oct. 20, 2025, 5:16 a.m. OK Java 8 TESTS 24 1452 0
344769677 abhayrajnegi0416 C1 Oct. 19, 2025, 7:29 p.m. OK Java 8 TESTS 22 1734 4915200
344798337 viditanupgupta C1 Oct. 20, 2025, 3:24 a.m. OK PyPy 3-64 TESTS 23 250 34201600
344800207 maurine26 C1 Oct. 20, 2025, 3:49 a.m. OK PyPy 3-64 TESTS 23 296 31334400
344801839 gjaynir0508 C1 Oct. 20, 2025, 4:12 a.m. OK PyPy 3-64 TESTS 23 312 24883200
344804836 chastertlye C1 Oct. 20, 2025, 4:52 a.m. OK PyPy 3-64 TESTS 24 327 33177600
344779355 sohamgupta.1515 C1 Oct. 19, 2025, 9:16 p.m. OK PyPy 3-64 TESTS 22 342 35737600
344779234 Aspiring_chocker C1 Oct. 19, 2025, 9:15 p.m. OK PyPy 3-64 TESTS 22 342 35737600
344800875 DivyamAwasthy C1 Oct. 20, 2025, 3:59 a.m. OK PyPy 3-64 TESTS 23 343 25804800
344745159 atharv_and C1 Oct. 19, 2025, 4:34 p.m. OK PyPy 3-64 TESTS 21 359 35430400
344785065 Mottchan123 C1 Oct. 19, 2025, 11:05 p.m. OK PyPy 3-64 TESTS 22 374 26316800
344787020 alexwice C1 Oct. 20, 2025, 12:01 a.m. OK PyPy 3-64 TESTS 22 374 37785600
344812359 Dhruthi_MS C1 Oct. 20, 2025, 6:07 a.m. OK Python 3 TESTS 24 515 46080000
344761618 Soultaker C1 Oct. 19, 2025, 6:30 p.m. OK Python 3 TESTS 22 593 45977600
344793091 lovmilkdragon C1 Oct. 20, 2025, 2:07 a.m. OK Python 3 TESTS 22 827 44646400
344785182 jai_gurudev C1 Oct. 19, 2025, 11:08 p.m. OK Python 3 TESTS 22 921 25088000
344768260 Argonised C1 Oct. 19, 2025, 7:18 p.m. OK Python 3 TESTS 22 921 25088000
344792911 lovmilkdragon C1 Oct. 20, 2025, 2:04 a.m. OK Python 3 TESTS 22 1014 46796800
344745390 anuhya_irrinki C1 Oct. 19, 2025, 4:34 p.m. OK Python 3 TESTS 21 1155 26931200
344796663 simhanarasimha675 C1 Oct. 20, 2025, 3:01 a.m. OK Python 3 TESTS 22 1640 25088000
344803876 kavya8 C1 Oct. 20, 2025, 4:39 a.m. OK Python 3 TESTS 24 1656 23142400
344745352 pravalikaindupalli C1 Oct. 19, 2025, 4:34 p.m. OK Python 3 TESTS 21 1765 23142400
344801215 Spheniscine C1 Oct. 20, 2025, 4:03 a.m. OK Rust 2021 TESTS 23 124 307200
344782260 0x81 C1 Oct. 19, 2025, 10:02 p.m. OK Rust 2024 TESTS 22 108 1331200
344770201 0x81 C1 Oct. 19, 2025, 7:33 p.m. OK Rust 2024 TESTS 22 265 1433600

remove filters

Back to search problems