Codeforces Round 1072 (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
2184 Codeforces Round 1072 (Div. 3) FINISHED False 8100 8177123 Jan. 12, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 21598 ) C Huge Pile PROGRAMMING binary search math

Andrei has a huge pile of (n) apples. He can divide the pile into two smaller piles: if there are (x) apples in the pile, he will get piles with (\lfloor \frac{x}{2} \rfloor)(^{\text{∗}}) and (\lceil \frac{x}{2} \rceil)(^{\text{†}}) apples. This division takes Andrei (1) minute. Andrei wants to eat (k) apples, but he doesn't want to count them at all. That is why he wants to obtain a pile that contains exactly (k) apples. Determine whether it is possible to achieve this by performing pile divisions. If it is possible, find the minimum possible time for Andrei to obtain a pile with exactly (k) apples. (^{\text{∗}})(\lfloor \frac{x}{2} \rfloor) — the largest integer (\le \frac{x}{2}). (^{\text{†}})(\lceil \frac{x}{2} \rceil) — the smallest integer (\ge \frac{x}{2}). Each test consists of several test cases. The first line contains a single integer (t) ((1 \le t \le 10^4)) — the number of test cases. The following lines describe the test cases. In the only line of each test case, two integers (n) and (k) are given — the number of apples in the huge pile and the number of apples that Andrei wants to obtain in one pile ((1 \le n, k \le 10^9)). For each test case, output (-1) if it is impossible to obtain a pile with exactly (k) apples. Otherwise, output the minimum possible time required to obtain such a pile. In the first test case, after the first division, two piles of (5) apples will be created. If one of them is divided, it will result in piles with (2) and (3) apples, so the answer is (2). In the second test case, if the pile is divided into two, it will result in piles with (5) and (6) apples, so the answer is (1). In the third test case, it is only possible to obtain piles with (1), (2), (3), (5), (6), (10), (11), or (21) apples, so the answer is (-1).

Tutorials

Codeforces Round 1072 (Div. 3) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
357768277 Abhii_shek3 C Jan. 13, 2026, 11:28 p.m. OK C# 13 TESTS 15 125 9318400
357714947 Raydzen C Jan. 13, 2026, 2:29 p.m. OK C++17 (GCC 7-32) TESTS 15 31 0
357696053 sanket890 C Jan. 13, 2026, 12:09 p.m. OK C++17 (GCC 7-32) TESTS 15 31 0
357681166 n_cube C Jan. 13, 2026, 9:59 a.m. OK C++17 (GCC 7-32) TESTS 15 31 0
357677160 koushik79 C Jan. 13, 2026, 9:25 a.m. OK C++17 (GCC 7-32) TESTS 15 31 0
357657767 Kashyap_Saniyara_33 C Jan. 13, 2026, 5:48 a.m. OK C++17 (GCC 7-32) TESTS 15 31 0
357751234 ritik_0707 C Jan. 13, 2026, 6:40 p.m. OK C++17 (GCC 7-32) TESTS 15 31 102400
357748503 hcodes C Jan. 13, 2026, 6:21 p.m. OK C++17 (GCC 7-32) TESTS 15 31 102400
357712219 wdang2010 C Jan. 13, 2026, 2:09 p.m. OK C++17 (GCC 7-32) TESTS 15 31 102400
357756429 nio2004 C Jan. 13, 2026, 7:25 p.m. OK C++17 (GCC 7-32) TESTS 15 31 819200
357771886 Abdulla_Ahmed_ C Jan. 14, 2026, 1:39 a.m. OK C++17 (GCC 7-32) TESTS 15 46 0
357782341 Hayashi C Jan. 14, 2026, 5:13 a.m. OK C++20 (GCC 13-64) TESTS 15 31 0
357763502 Interstellar001 C Jan. 13, 2026, 9:03 p.m. OK C++20 (GCC 13-64) TESTS 15 31 0
357721745 god_harsh C Jan. 13, 2026, 3:24 p.m. OK C++20 (GCC 13-64) TESTS 15 31 0
357713855 kidneystonecoldy C Jan. 13, 2026, 2:21 p.m. OK C++20 (GCC 13-64) TESTS 15 31 0
357701660 T52T52 C Jan. 13, 2026, 12:54 p.m. OK C++20 (GCC 13-64) TESTS 15 31 0
357679356 fiza C Jan. 13, 2026, 9:43 a.m. OK C++20 (GCC 13-64) TESTS 15 31 0
357679276 meowwwwwwwwww C Jan. 13, 2026, 9:42 a.m. OK C++20 (GCC 13-64) TESTS 15 31 0
357675488 VCodes_07 C Jan. 13, 2026, 9:12 a.m. OK C++20 (GCC 13-64) TESTS 15 31 0
357675374 siyam35 C Jan. 13, 2026, 9:11 a.m. OK C++20 (GCC 13-64) TESTS 15 31 0
357780989 not_from_iit_d C Jan. 14, 2026, 4:53 a.m. OK C++20 (GCC 13-64) TESTS 15 31 102400
357781232 Abhin_07av C Jan. 14, 2026, 4:57 a.m. OK C++23 (GCC 14-64, msys2) TESTS 15 31 0
357734926 GILGAMESH C Jan. 13, 2026, 4:57 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 31 0
357724800 udaygupta8899 C Jan. 13, 2026, 3:48 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 31 0
357712881 ami_XR C Jan. 13, 2026, 2:14 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 31 0
357709512 parameciumQAQ C Jan. 13, 2026, 1:51 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 31 0
357707366 si_sii C Jan. 13, 2026, 1:36 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 31 0
357704366 Melodylll C Jan. 13, 2026, 1:14 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 31 0
357701736 Journey__ C Jan. 13, 2026, 12:54 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 31 0
357699023 Recursive789 C Jan. 13, 2026, 12:33 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 31 0
357698942 Mindmaster48 C Jan. 13, 2026, 12:33 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 31 0
357774644 amit1_137 C Jan. 14, 2026, 2:56 a.m. OK GNU C11 TESTS 15 62 0
357773552 yvzuojianlianzi C Jan. 14, 2026, 2:29 a.m. OK GNU C11 TESTS 15 62 0
357772283 yvzuojianlianzi C Jan. 14, 2026, 1:52 a.m. OK GNU C11 TESTS 15 62 0
357754457 Shivvelnad C Jan. 13, 2026, 7:08 p.m. OK GNU C11 TESTS 15 62 0
357748653 ayan24bits C Jan. 13, 2026, 6:22 p.m. OK GNU C11 TESTS 15 62 0
357777933 ajgar_badmash7 C Jan. 14, 2026, 3:58 a.m. OK GNU C11 TESTS 15 78 0
357777878 Ayush_Kumar_Sharma C Jan. 14, 2026, 3:57 a.m. OK GNU C11 TESTS 15 78 0
357725213 INFINITYRUSH C Jan. 13, 2026, 3:51 p.m. OK GNU C11 TESTS 15 78 0
357700228 250511630_sunyu C Jan. 13, 2026, 12:43 p.m. OK GNU C11 TESTS 15 78 0
357696273 ab_211111 C Jan. 13, 2026, 12:10 p.m. OK GNU C11 TESTS 15 78 0
357779830 Leeeee C Jan. 14, 2026, 4:34 a.m. OK Go TESTS 15 78 512000
357654830 LittleGopher C Jan. 13, 2026, 5:11 a.m. OK Go TESTS 15 125 4915200
357733697 VivirAstucia C Jan. 13, 2026, 4:49 p.m. OK Haskell TESTS 15 109 102400
357786094 dxtmanav C Jan. 14, 2026, 6:03 a.m. OK Java 21 TESTS 15 203 409600
357783418 cpp10 C Jan. 14, 2026, 5:28 a.m. OK Java 21 TESTS 15 218 614400
357721647 unleashed_me C Jan. 13, 2026, 3:23 p.m. OK Java 21 TESTS 15 218 1331200
357719035 rex1224 C Jan. 13, 2026, 3:02 p.m. OK Java 21 TESTS 15 218 42291200
357784495 naveenmandal C Jan. 14, 2026, 5:43 a.m. OK Java 21 TESTS 15 234 512000
357783485 cpp10 C Jan. 14, 2026, 5:29 a.m. OK Java 21 TESTS 15 234 512000
357786340 Pratham_Tiwari C Jan. 14, 2026, 6:06 a.m. OK Java 21 TESTS 15 234 819200
357701645 SathvikGoud C Jan. 13, 2026, 12:54 p.m. OK Java 21 TESTS 15 250 307200
357783710 naveenmandal C Jan. 14, 2026, 5:32 a.m. OK Java 21 TESTS 15 250 512000
357738073 Diffusity_2005 C Jan. 13, 2026, 5:17 p.m. OK Java 21 TESTS 15 250 614400
357761607 C47KIKI C Jan. 13, 2026, 8:31 p.m. OK Java 8 TESTS 15 125 0
357718521 niteshkaushik200 C Jan. 13, 2026, 2:58 p.m. OK Java 8 TESTS 15 156 0
357718280 Picklzes C Jan. 13, 2026, 2:56 p.m. OK Java 8 TESTS 15 156 0
357773102 chengzijun_de_xiatian C Jan. 14, 2026, 2:17 a.m. OK Java 8 TESTS 15 187 0
357768082 Twinkal24 C Jan. 13, 2026, 11:19 p.m. OK Java 8 TESTS 15 187 0
357686445 jroy.karnati C Jan. 13, 2026, 10:48 a.m. OK Java 8 TESTS 15 187 0
357693461 talhaanjum C Jan. 13, 2026, 11:47 a.m. OK Java 8 TESTS 15 250 0
357765222 arvindf232 C Jan. 13, 2026, 9:42 p.m. OK Kotlin 2.2 TESTS 15 406 27136000
357655882 Nafosat_1306 C Jan. 13, 2026, 5:25 a.m. OK PyPy 3 TESTS 15 203 5939200
357735747 itscris7777777 C Jan. 13, 2026, 5:02 p.m. OK PyPy 3 TESTS 15 312 7270400
357723764 __darkrai__ C Jan. 13, 2026, 3:40 p.m. OK PyPy 3 TESTS 15 484 10752000
357742920 jinx_1407 C Jan. 13, 2026, 5:47 p.m. OK PyPy 3-64 TESTS 15 78 3072000
357691427 HumbleRobo C Jan. 13, 2026, 11:30 a.m. OK PyPy 3-64 TESTS 15 78 3891200
357699776 shubham6105 C Jan. 13, 2026, 12:39 p.m. OK PyPy 3-64 TESTS 15 93 4300800
357729497 sanchit_kumar C Jan. 13, 2026, 4:22 p.m. OK PyPy 3-64 TESTS 15 93 4915200
357682242 tingshuo2917 C Jan. 13, 2026, 10:09 a.m. OK PyPy 3-64 TESTS 15 93 265011200
357783390 himnariya C Jan. 14, 2026, 5:27 a.m. OK PyPy 3-64 TESTS 15 109 4300800
357683214 mohd_fariq C Jan. 13, 2026, 10:18 a.m. OK PyPy 3-64 TESTS 15 109 5324800
357677462 shyro8998 C Jan. 13, 2026, 9:28 a.m. OK PyPy 3-64 TESTS 15 109 7168000
357693999 MohamedAdel_2025 C Jan. 13, 2026, 11:51 a.m. OK PyPy 3-64 TESTS 15 125 3686400
357715512 zahid147 C Jan. 13, 2026, 2:34 p.m. OK PyPy 3-64 TESTS 15 125 3788800
357741056 co_ron C Jan. 13, 2026, 5:35 p.m. OK Python 3 TESTS 15 109 2969600
357716374 soundarzozm C Jan. 13, 2026, 2:41 p.m. OK Python 3 TESTS 15 140 204800
357676767 OjasKugore C Jan. 13, 2026, 9:22 a.m. OK Python 3 TESTS 15 140 2764800
357721854 22pa1a05f9 C Jan. 13, 2026, 3:25 p.m. OK Python 3 TESTS 15 156 2764800
357775616 hundunlilun1 C Jan. 14, 2026, 3:16 a.m. OK Python 3 TESTS 15 171 102400
357737663 UB04 C Jan. 13, 2026, 5:14 p.m. OK Python 3 TESTS 15 171 102400
357725182 rakshit__modi C Jan. 13, 2026, 3:51 p.m. OK Python 3 TESTS 15 187 102400
357712434 KevZ3742 C Jan. 13, 2026, 2:11 p.m. OK Python 3 TESTS 15 187 102400
357752359 kazu_tech C Jan. 13, 2026, 6:50 p.m. OK Python 3 TESTS 15 203 102400
357673194 ColabottleDaniorerio C Jan. 13, 2026, 8:51 a.m. OK Python 3 TESTS 15 218 102400
357784258 Spheniscine C Jan. 14, 2026, 5:39 a.m. OK Rust 2021 TESTS 15 31 102400
357773836 hirose2020 C Jan. 14, 2026, 2:36 a.m. OK Rust 2024 TESTS 15 46 11776000
357726550 GUAIKATTO C Jan. 13, 2026, 4:01 p.m. OK Rust 2024 TESTS 15 46 24473600
357725809 aeriesha C Jan. 13, 2026, 3:56 p.m. OK Rust 2024 TESTS 15 62 0

remove filters

Back to search problems