Codeforces Round 1042 (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
2131 Codeforces Round 1042 (Div. 3) FINISHED False 8100 21569123 Aug. 10, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 38711 ) A Lever PROGRAMMING math

In Divergent Universe, The Lever iterates itself given two arrays (a) and (b) of length (n). In each iteration, The Lever will do the following: Choose a random index (i) such that (a_i > b_i). Then, decrease (a_i) by (1). If there does not exist such (i), ignore this step. Choose a random index (i) such that (a_i < b_i). Then, increase (a_i) by (1). If there does not exist such (i), ignore this step. After each iteration, the Lever will check if step (1) is ignored, and if so, it will end its iteration. You're given the two arrays. Find the number of iterations that the Lever does. It can be shown this number is fixed over all possibilities of random indices that The Lever can choose for each step. 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 one integer (n) ((1 \le n \le 10)). The second line of each test case contains (n) integers (a_1, a_2, \dots, a_n) ((1 \le a_i \le 10)). The third line of each test case contains (n) integers (b_1, b_2, \dots, b_n) ((1 \le b_i \le 10)). For each test case, output one integer — the number of iterations that the Lever does. In the first sample case: In the first iteration, the Lever decreases (a_1) by (1) and increases (a_2) by (1), and (a) becomes (6,4). In the second iteration, the Lever decreases (a_1) by (1) and increases (a_2) by (1), and (a) becomes (5,5). In the third iteration, the Lever increases (a_2) by (1), and (a) becomes (5,6). Since it fails to decrease an element, its iteration ends. Therefore, the answer is (3). In the second sample case, the Lever does nothing in its first iteration, and thus it does only one iteration.

Tutorials

Codeforces Round 1042 (Div. 3) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
333450811 og.kostya A Aug. 10, 2025, 5:17 p.m. OK C# 13 TESTS 2 61 1024000
333453380 Bajoriya_Vaibhav A Aug. 10, 2025, 5:36 p.m. OK C++17 (GCC 7-32) TESTS 2 30 0
333453116 nitishkumar02032004 A Aug. 10, 2025, 5:34 p.m. OK C++17 (GCC 7-32) TESTS 2 30 0
333492344 arcanum01 A Aug. 11, 2025, 4:51 a.m. OK C++17 (GCC 7-32) TESTS 2 31 0
333487225 abhi_8923 A Aug. 11, 2025, 3:35 a.m. OK C++17 (GCC 7-32) TESTS 2 31 0
333469629 tomak A Aug. 10, 2025, 9:04 p.m. OK C++17 (GCC 7-32) TESTS 2 31 0
333460550 MasterChief410 A Aug. 10, 2025, 6:45 p.m. OK C++17 (GCC 7-32) TESTS 2 31 0
333453109 i9u07 A Aug. 10, 2025, 5:34 p.m. OK C++17 (GCC 7-32) TESTS 2 31 0
333452065 IamPrateek45 A Aug. 10, 2025, 5:26 p.m. OK C++17 (GCC 7-32) TESTS 2 31 0
333497301 fsenekal A Aug. 11, 2025, 5:48 a.m. OK C++17 (GCC 7-32) TESTS 2 31 0
333496880 Risinghope_willfightback A Aug. 11, 2025, 5:43 a.m. OK C++17 (GCC 7-32) TESTS 2 31 0
333477698 syed226 A Aug. 11, 2025, 1:12 a.m. OK C++20 (GCC 13-64) TESTS 2 15 0
333480209 himsog A Aug. 11, 2025, 1:55 a.m. OK C++20 (GCC 13-64) TESTS 2 30 0
333497881 salman_jewel A Aug. 11, 2025, 5:53 a.m. OK C++20 (GCC 13-64) TESTS 2 30 0
333493817 tanvir_islam A Aug. 11, 2025, 5:11 a.m. OK C++20 (GCC 13-64) TESTS 2 30 0
333486895 1qaz1 A Aug. 11, 2025, 3:30 a.m. OK C++20 (GCC 13-64) TESTS 2 30 0
333478685 deep_n_drap A Aug. 11, 2025, 1:31 a.m. OK C++20 (GCC 13-64) TESTS 2 30 0
333478345 ___PatrickChen___ A Aug. 11, 2025, 1:25 a.m. OK C++20 (GCC 13-64) TESTS 2 30 0
333461045 Lunar_Dragon A Aug. 10, 2025, 6:50 p.m. OK C++20 (GCC 13-64) TESTS 2 30 0
333455698 Trivagohehe A Aug. 10, 2025, 5:56 p.m. OK C++20 (GCC 13-64) TESTS 2 30 0
333447577 cdjs1432 A Aug. 10, 2025, 4:59 p.m. OK C++20 (GCC 13-64) TESTS 2 30 0
333456321 Aidarhan-N-014-2029 A Aug. 10, 2025, 6:01 p.m. OK C++23 (GCC 14-64, msys2) TESTS 2 30 0
333494957 nurikgod A Aug. 11, 2025, 5:25 a.m. OK C++23 (GCC 14-64, msys2) TESTS 2 30 0
333492731 Sumit2023102 A Aug. 11, 2025, 4:57 a.m. OK C++23 (GCC 14-64, msys2) TESTS 2 30 0
333488625 Shankha2005 A Aug. 11, 2025, 3:56 a.m. OK C++23 (GCC 14-64, msys2) TESTS 2 30 0
333477031 wanli_ A Aug. 11, 2025, 12:58 a.m. OK C++23 (GCC 14-64, msys2) TESTS 2 30 0
333469210 GHader_Ibrahim A Aug. 10, 2025, 8:55 p.m. OK C++23 (GCC 14-64, msys2) TESTS 2 30 0
333466638 LiQingning A Aug. 10, 2025, 8:08 p.m. OK C++23 (GCC 14-64, msys2) TESTS 2 30 0
333466624 SyntaxGambit A Aug. 10, 2025, 8:08 p.m. OK C++23 (GCC 14-64, msys2) TESTS 2 30 0
333462643 RiteshRaushan A Aug. 10, 2025, 7:10 p.m. OK C++23 (GCC 14-64, msys2) TESTS 2 30 0
333457627 SerajOmar A Aug. 10, 2025, 6:14 p.m. OK C++23 (GCC 14-64, msys2) TESTS 2 30 0
333476298 bluemegane A Aug. 11, 2025, 12:40 a.m. OK C# 8 TESTS 2 92 2969600
333492674 AttractorsTheory A Aug. 11, 2025, 4:56 a.m. OK GNU C11 TESTS 2 61 307200
333447603 Mufasa06 A Aug. 10, 2025, 4:59 p.m. OK GNU C11 TESTS 2 62 102400
333479356 sons1111 A Aug. 11, 2025, 1:43 a.m. OK GNU C11 TESTS 2 77 0
333446540 ayan24bits A Aug. 10, 2025, 4:54 p.m. OK GNU C11 TESTS 2 93 0
333444369 ar_prosonno A Aug. 10, 2025, 4:48 p.m. OK GNU C11 TESTS 2 93 0
333486999 MonkeBanan A Aug. 11, 2025, 3:31 a.m. OK GNU C11 TESTS 2 93 102400
333466582 tahsin_ferdous A Aug. 10, 2025, 8:07 p.m. OK Go TESTS 2 281 4300800
333468448 Romicus A Aug. 10, 2025, 8:39 p.m. OK Haskell TESTS 2 202 0
333481576 fire12324344 A Aug. 11, 2025, 2:16 a.m. OK Java 21 TESTS 2 155 0
333483723 arpande97 A Aug. 11, 2025, 2:45 a.m. OK Java 21 TESTS 2 186 409600
333453604 Krishna_11111 A Aug. 10, 2025, 5:38 p.m. OK Java 21 TESTS 2 202 0
333450406 qavkour A Aug. 10, 2025, 5:15 p.m. OK Java 21 TESTS 2 202 0
333448512 arpit_ehh A Aug. 10, 2025, 5:03 p.m. OK Java 21 TESTS 2 202 0
333452579 kjx_23 A Aug. 10, 2025, 5:30 p.m. OK Java 21 TESTS 2 202 307200
333479913 TripleThread A Aug. 11, 2025, 1:51 a.m. OK Java 21 TESTS 2 202 42393600
333478337 oneafter A Aug. 11, 2025, 1:25 a.m. OK Java 21 TESTS 2 217 0
333447654 joseantonio.vegaruiz A Aug. 10, 2025, 4:59 p.m. OK Java 21 TESTS 2 217 0
333497014 divyanshnm A Aug. 11, 2025, 5:45 a.m. OK Java 21 TESTS 2 218 307200
333462105 yashvardhan3 A Aug. 10, 2025, 7:03 p.m. OK Java 8 TESTS 2 124 0
333460689 heronmoy.emon A Aug. 10, 2025, 6:46 p.m. OK Java 8 TESTS 2 124 0
333447576 2manas1 A Aug. 10, 2025, 4:59 p.m. OK Java 8 TESTS 2 140 0
333466124 shreekarunam A Aug. 10, 2025, 8 p.m. OK Java 8 TESTS 2 249 0
333447201 PanduVarun A Aug. 10, 2025, 4:57 p.m. OK Java 8 TESTS 2 249 0
333488499 andrewchin530 A Aug. 11, 2025, 3:54 a.m. OK Java 8 TESTS 2 264 0
333466901 janhvi_awasthi A Aug. 10, 2025, 8:13 p.m. OK Java 8 TESTS 2 264 0
333462858 kripu-star A Aug. 10, 2025, 7:13 p.m. OK Java 8 TESTS 2 264 0
333463827 sadafnizam94 A Aug. 10, 2025, 7:25 p.m. OK Java 8 TESTS 2 265 0
333457973 yashbansal99 A Aug. 10, 2025, 6:18 p.m. OK Java 8 TESTS 2 280 0
333470941 ApuMorales A Aug. 10, 2025, 9:34 p.m. OK PyPy 3 TESTS 2 296 6348800
333452086 Grigory09 A Aug. 10, 2025, 5:26 p.m. OK PyPy 3 TESTS 2 328 6758400
333494006 arwing A Aug. 11, 2025, 5:13 a.m. OK PyPy 3 TESTS 2 405 8601600
333458617 bishoprunner A Aug. 10, 2025, 6:24 p.m. OK PyPy 3-64 TESTS 2 77 3788800
333472978 judival30 A Aug. 10, 2025, 10:37 p.m. OK PyPy 3-64 TESTS 2 93 3788800
333464555 jvatsal0709 A Aug. 10, 2025, 7:35 p.m. OK PyPy 3-64 TESTS 2 93 3891200
333459650 Jonivo A Aug. 10, 2025, 6:34 p.m. OK PyPy 3-64 TESTS 2 124 3788800
333455886 gardengnome A Aug. 10, 2025, 5:57 p.m. OK PyPy 3-64 TESTS 2 124 4403200
333465491 zeyadfarhat11 A Aug. 10, 2025, 7:50 p.m. OK PyPy 3-64 TESTS 2 124 4812800
333452924 abhinavguptaxia9213 A Aug. 10, 2025, 5:33 p.m. OK PyPy 3-64 TESTS 2 124 4915200
333464664 amongsus A Aug. 10, 2025, 7:37 p.m. OK PyPy 3-64 TESTS 2 124 5222400
333472960 alexwice A Aug. 10, 2025, 10:36 p.m. OK PyPy 3-64 TESTS 2 124 6860800
333460048 DarkTemplarDrop A Aug. 10, 2025, 6:39 p.m. OK PyPy 3-64 TESTS 2 124 6963200
333457550 FardeenMalikP A Aug. 10, 2025, 6:13 p.m. OK Python 3 TESTS 2 93 102400
333479802 ad3301 A Aug. 11, 2025, 1:49 a.m. OK Python 3 TESTS 2 93 3993600
333497074 aneesh2002 A Aug. 11, 2025, 5:45 a.m. OK Python 3 TESTS 2 108 819200
333445376 singhekas0202 A Aug. 10, 2025, 4:49 p.m. OK Python 3 TESTS 2 109 0
333477651 Python_11127 A Aug. 11, 2025, 1:11 a.m. OK Python 3 TESTS 2 109 204800
333498222 gian_notty A Aug. 11, 2025, 5:57 a.m. OK Python 3 TESTS 2 124 0
333483111 letmecookthis12344321 A Aug. 11, 2025, 2:37 a.m. OK Python 3 TESTS 2 124 0
333478320 fly_highvd A Aug. 11, 2025, 1:24 a.m. OK Python 3 TESTS 2 124 0
333472848 coder.sy A Aug. 10, 2025, 10:32 p.m. OK Python 3 TESTS 2 124 0
333449653 MallikarjunaReddyThota A Aug. 10, 2025, 5:10 p.m. OK Python 3 TESTS 2 124 0
333462978 WORTH A Aug. 10, 2025, 7:15 p.m. OK Rust 2021 TESTS 2 46 0

remove filters

Back to search problems