Codeforces Round 1023 (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
2107 Codeforces Round 1023 (Div. 2) FINISHED False 8100 29949923 May 5, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 19652 ) B Apples in Boxes PROGRAMMING games greedy math

Tom and Jerry found some apples in the basement. They decided to play a game to get some apples. There are (n) boxes, and the (i)-th box has (a_i) apples inside. Tom and Jerry take turns picking up apples. Tom goes first. On their turn, they have to do the following: Choose a box (i) ((1 \le i \le n)) with a positive number of apples, i.e. (a_i > 0), and pick (1) apple from this box. Note that this reduces (a_i) by (1). If no valid box exists, the current player loses. If after the move , (\max(a_1, a_2, \ldots, a_n) - \min(a_1, a_2, \ldots, a_n) > k) holds, then the current player (who made the last move) also loses. If both players play optimally, predict the winner of the game. 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,k) ((2 \le n \le 10^5,1\le k \le 10^9)). The second line of each test case contains (n) integers (a_1, a_2, \ldots, a_n) ((1 \le a_i \le 10^9)). It is guaranteed that the sum of (n) over all test cases does not exceed (10^5). For each test case, print "Tom" (without quotes) if Tom will win, or "Jerry" (without quotes) otherwise. Note that neither player is necessarily playing an optimal strategy in the following games, just to give you an idea of how the game is going. In the first test case of the example, one possible situation is shown as follows. Tom takes an apple from the first box. The array (a) becomes (1, 1, 2). Tom does not lose because (\max(1, 1, 2) - \min(1, 1, 2) = 1 \le k). Jerry takes an apple from the first box as well. The array (a) becomes (0, 1, 2). Jerry loses because (\max(0, 1, 2) - \min(0, 1, 2) = 2 > k).

Tutorials

Codeforces Round 1023 (Div 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
318570791 faishal_052 B May 6, 2025, 2:05 a.m. OK C# 10 TESTS 10 109 7987200
318570415 shahadat26 B May 6, 2025, 1:56 a.m. OK C# 10 TESTS 10 109 7987200
318520280 Ilya1995 B May 5, 2025, 4:26 p.m. OK C# 10 TESTS 10 124 7475200
318540744 -firefly- B May 5, 2025, 5:59 p.m. OK C# 10 TESTS 10 202 10444800
318568242 linjiangxianwww B May 6, 2025, 1:06 a.m. OK C++17 (GCC 7-32) TESTS 10 61 0
318566764 arghodatta B May 6, 2025, 12:26 a.m. OK C++17 (GCC 7-32) TESTS 10 61 0
318552567 ankit1373 B May 5, 2025, 8:20 p.m. OK C++17 (GCC 7-32) TESTS 10 61 0
318542978 floxi4 B May 5, 2025, 6:19 p.m. OK C++17 (GCC 7-32) TESTS 10 61 0
318542506 jelly_MIZUKI B May 5, 2025, 6:14 p.m. OK C++17 (GCC 7-32) TESTS 10 61 0
318576156 the_faiz2 B May 6, 2025, 3:51 a.m. OK C++17 (GCC 7-32) TESTS 10 61 102400
318550362 AhmedQassem_ B May 5, 2025, 7:45 p.m. OK C++17 (GCC 7-32) TESTS 10 61 3276800
318583585 shxun B May 6, 2025, 5:48 a.m. OK C++17 (GCC 7-32) TESTS 10 62 0
318583142 NIKKA777 B May 6, 2025, 5:42 a.m. OK C++17 (GCC 7-32) TESTS 10 62 0
318582765 SSShanuu B May 6, 2025, 5:37 a.m. OK C++17 (GCC 7-32) TESTS 10 62 0
318583773 ryuuko_ B May 6, 2025, 5:51 a.m. OK C++20 (GCC 13-64) TESTS 10 61 0
318573865 golam_kibriya_fahim B May 6, 2025, 3:08 a.m. OK C++20 (GCC 13-64) TESTS 10 61 0
318573117 M_Elgamal B May 6, 2025, 2:53 a.m. OK C++20 (GCC 13-64) TESTS 10 61 0
318570636 leviathanX B May 6, 2025, 2:02 a.m. OK C++20 (GCC 13-64) TESTS 10 61 0
318569794 wxzeya B May 6, 2025, 1:43 a.m. OK C++20 (GCC 13-64) TESTS 10 61 0
318561279 Victor_J B May 6, 2025, 12:06 a.m. OK C++20 (GCC 13-64) TESTS 10 61 0
318547688 singh75 B May 5, 2025, 7:10 p.m. OK C++20 (GCC 13-64) TESTS 10 61 0
318543387 Codeslinger_alpha B May 5, 2025, 6:23 p.m. OK C++20 (GCC 13-64) TESTS 10 61 0
318537666 sailealt31 B May 5, 2025, 5:35 p.m. OK C++20 (GCC 13-64) TESTS 10 61 0
318526599 richi78 B May 5, 2025, 4:45 p.m. OK C++20 (GCC 13-64) TESTS 10 61 0
318575351 ashraftanvir01 B May 6, 2025, 3:36 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 46 0
318545808 abrarxawad B May 5, 2025, 6:48 p.m. OK C++23 (GCC 14-64, msys2) TESTS 10 46 0
318540400 Hadi_Alhamed B May 5, 2025, 5:56 p.m. OK C++23 (GCC 14-64, msys2) TESTS 10 46 0
318583770 Mayank016 B May 6, 2025, 5:50 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 46 102400
318580441 uddhav_Nagar B May 6, 2025, 5:06 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 61 0
318577556 MervinLuo B May 6, 2025, 4:16 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 61 0
318573288 DBP_Heaven B May 6, 2025, 2:57 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 61 0
318566545 mohassan.dev B May 6, 2025, 12:20 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 61 0
318566378 A_G B May 6, 2025, 12:16 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 61 0
318554710 Hard_Nut B May 5, 2025, 8:56 p.m. OK C++23 (GCC 14-64, msys2) TESTS 10 61 0
318537794 ruban B May 5, 2025, 5:36 p.m. OK FPC TESTS 10 93 55500800
318546445 1435730 B May 5, 2025, 6:55 p.m. OK GNU C11 TESTS 10 77 512000
318526340 SupremoCoder B May 5, 2025, 4:44 p.m. OK GNU C11 TESTS 10 77 819200
318566959 Hakunaaa B May 6, 2025, 12:31 a.m. OK GNU C11 TESTS 10 93 102400
318527787 rayahazari B May 5, 2025, 4:48 p.m. OK GNU C11 TESTS 10 108 409600
318547351 hw3901 B May 5, 2025, 7:06 p.m. OK GNU C11 TESTS 10 109 921600
318538982 the_bigShort B May 5, 2025, 5:44 p.m. OK Java 21 TESTS 10 249 409600
318559340 bomakhamchha B May 5, 2025, 10:56 p.m. OK Java 21 TESTS 10 249 1024000
318575232 akshatsaxena552004.ss B May 6, 2025, 3:34 a.m. OK Java 21 TESTS 10 265 409600
318577994 StringerBell B May 6, 2025, 4:24 a.m. OK Java 21 TESTS 10 265 921600
318555003 sarthakkharka808 B May 5, 2025, 9:02 p.m. OK Java 21 TESTS 10 265 1843200
318578081 sagar19197 B May 6, 2025, 4:26 a.m. OK Java 21 TESTS 10 280 3276800
318579521 sahil_14 B May 6, 2025, 4:52 a.m. OK Java 21 TESTS 10 281 921600
318520457 kumargaurav9817 B May 5, 2025, 4:27 p.m. OK Java 21 TESTS 10 296 307200
318536960 fayroz B May 5, 2025, 5:31 p.m. OK Java 21 TESTS 10 296 716800
318549656 tekka_ity B May 5, 2025, 7:34 p.m. OK Java 21 TESTS 10 296 819200
318579240 Dduo B May 6, 2025, 4:46 a.m. OK Java 8 TESTS 10 171 0
318539436 y_a_s B May 5, 2025, 5:48 p.m. OK Java 8 TESTS 10 171 0
318573224 prime29 B May 6, 2025, 2:55 a.m. OK Java 8 TESTS 10 187 0
318574344 kartik__sethi B May 6, 2025, 3:18 a.m. OK Java 8 TESTS 10 187 307200
318545118 Tharun_Reddy_ B May 5, 2025, 6:41 p.m. OK Java 8 TESTS 10 202 0
318525101 ankit_bit B May 5, 2025, 4:41 p.m. OK Java 8 TESTS 10 218 0
318576456 Pranav_45 B May 6, 2025, 3:57 a.m. OK Java 8 TESTS 10 218 204800
318584678 rohitashwant45 B May 6, 2025, 6:02 a.m. OK Java 8 TESTS 10 281 0
318541306 Ishaan__23 B May 5, 2025, 6:03 p.m. OK Java 8 TESTS 10 281 0
318544836 only_forward_ B May 5, 2025, 6:38 p.m. OK Java 8 TESTS 10 296 0
318540376 kamlesh_kaparvena B May 5, 2025, 5:55 p.m. OK PyPy 3 TESTS 10 280 10137600
318584536 santhoshsparky B May 6, 2025, 6:01 a.m. OK PyPy 3 TESTS 10 358 10444800
318573424 Akash_123 B May 6, 2025, 2:59 a.m. OK PyPy 3 TESTS 10 359 10547200
318573571 Akash_123 B May 6, 2025, 3:02 a.m. OK PyPy 3 TESTS 10 390 10547200
318521722 dreamer_empty B May 5, 2025, 4:31 p.m. OK PyPy 3 TESTS 10 405 10854400
318537070 dm1triysergeev B May 5, 2025, 5:31 p.m. OK PyPy 3 TESTS 10 421 10752000
318583256 Om_Singh_ B May 6, 2025, 5:44 a.m. OK PyPy 3-64 TESTS 10 140 13004800
318578062 Canyonzzzzz B May 6, 2025, 4:25 a.m. OK PyPy 3-64 TESTS 10 140 13004800
318573773 meow_love B May 6, 2025, 3:06 a.m. OK PyPy 3-64 TESTS 10 140 13209600
318541677 Anirban2046 B May 5, 2025, 6:07 p.m. OK PyPy 3-64 TESTS 10 140 13824000
318576425 cold_beans B May 6, 2025, 3:56 a.m. OK PyPy 3-64 TESTS 10 155 13107200
318568685 ste5 B May 6, 2025, 1:16 a.m. OK PyPy 3-64 TESTS 10 155 14336000
318536686 ramya_2129 B May 5, 2025, 5:29 p.m. OK PyPy 3-64 TESTS 10 171 12902400
318539078 TerryYangUSA B May 5, 2025, 5:45 p.m. OK PyPy 3-64 TESTS 10 171 14438400
318574705 hxu10 B May 6, 2025, 3:25 a.m. OK PyPy 3-64 TESTS 10 171 15872000
318528170 Sheree618 B May 5, 2025, 4:48 p.m. OK PyPy 3-64 TESTS 10 186 13312000
318542992 kundan_1209 B May 5, 2025, 6:19 p.m. OK Python 3 TESTS 10 108 13619200
318540310 phuocsang B May 5, 2025, 5:55 p.m. OK Python 3 TESTS 10 109 11468800
318522021 J-K B May 5, 2025, 4:32 p.m. OK Python 3 TESTS 10 109 12390400
318545723 andrewliu10523 B May 5, 2025, 6:48 p.m. OK Python 3 TESTS 10 124 11264000
318573267 eugalt B May 6, 2025, 2:56 a.m. OK Python 3 TESTS 10 124 12595200
318520564 dzh_pow B May 5, 2025, 4:27 p.m. OK Python 3 TESTS 10 124 12697600
318566757 eugalt B May 6, 2025, 12:26 a.m. OK Python 3 TESTS 10 124 14028800
318543637 tanvirmahfuz22 B May 5, 2025, 6:25 p.m. OK Python 3 TESTS 10 140 12595200
318521837 subhamgaurav011 B May 5, 2025, 4:31 p.m. OK Python 3 TESTS 10 140 12697600
318584783 SaurabhS97 B May 6, 2025, 6:04 a.m. OK Python 3 TESTS 10 140 12800000
318567497 silicalet B May 6, 2025, 12:46 a.m. OK Rust 2021 TESTS 10 93 4505600

remove filters

Back to search problems