Codeforces Round 1043 (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
2132 Codeforces Round 1043 (Div. 3) FINISHED False 8100 20618723 Aug. 21, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 13262 ) C2 The Cunning Seller (hard version) PROGRAMMING binary search greedy math

This is the hard version of the problem. The easy version differs from the hard one in that it requires determining the minimum cost with the least number of deals, while the hard version requires determining the minimum cost with a limited number of deals. After the cunning seller sold three watermelons instead of one, he decided to increase his profit — namely, he bought even more watermelons. Now he can sell (3^x) watermelons for (3^{x+1} + x \cdot 3^{x-1}) coins, where (x) is a non-negative integer. Such a sale is called a deal. A calculating buyer came to him, but he has little time, so the buyer can make no more than (k) deals and plans to buy exactly (n) watermelons. The buyer is in a hurry and has therefore turned to you to determine the minimum number of coins he must pay the seller for (n) watermelons if he makes no more than (k) deals. If it is impossible to buy exactly (n) watermelons while making no more than (k) deals, output (-1). The first line contains an integer (t) ((1 \le t \le 10^4)) — the number of test cases. The description of each test case follows. In a single line of each test case, there are two integers (n) and (k) ((1 \le n, k \le 10^9)) — how many watermelons need to be bought and how many deals can be made. For each test case, output a single integer — the minimum cost of the watermelons or (-1) if it is impossible to buy the watermelons while meeting all the conditions. Note that there is no point in buying more watermelons than needed, so we will not consider deals where there are more watermelons than necessary. Let's consider the costs of the first two deal options: Deal A: (1) watermelon — (3) coins. Deal B: (3) watermelons — (10) coins. In the first sample, the only way to buy (1) watermelon is to use Deal A, so the answer is (3). In the second sample, you can buy (3) watermelons either with Deal B for (10) coins or with thr

Tutorials

Codeforces Round 1043 (Div. 3) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
335082640 remantadin C2 Aug. 22, 2025, 7:28 p.m. OK C# 13 TESTS 6 139 3891200
335116810 og.kostya C2 Aug. 23, 2025, 6:09 a.m. OK C# 13 TESTS 6 155 3174400
335229297 Haidy_gamal C2 Aug. 24, 2025, 12:12 a.m. OK C++17 (GCC 7-32) TESTS 6 46 0
335129721 youxiking C2 Aug. 23, 2025, 8:03 a.m. OK C++17 (GCC 7-32) TESTS 6 46 0
335125403 Nexus_Fractal C2 Aug. 23, 2025, 7:28 a.m. OK C++17 (GCC 7-32) TESTS 6 46 0
335121685 wizzzzzz C2 Aug. 23, 2025, 6:55 a.m. OK C++17 (GCC 7-32) TESTS 6 46 0
335110982 viditpandey C2 Aug. 23, 2025, 5:04 a.m. OK C++17 (GCC 7-32) TESTS 6 46 0
335104196 lonely_warrior_lak0708 C2 Aug. 23, 2025, 3:22 a.m. OK C++17 (GCC 7-32) TESTS 6 46 0
335103060 Meteor2025 C2 Aug. 23, 2025, 3:03 a.m. OK C++17 (GCC 7-32) TESTS 6 46 0
335102999 Meteor2025 C2 Aug. 23, 2025, 3:02 a.m. OK C++17 (GCC 7-32) TESTS 6 46 0
335100437 CP_killer C2 Aug. 23, 2025, 2:02 a.m. OK C++17 (GCC 7-32) TESTS 6 46 0
335095708 shanmukh_123 C2 Aug. 22, 2025, 11:47 p.m. OK C++17 (GCC 7-32) TESTS 6 46 0
335235097 anywayimverycute C2 Aug. 24, 2025, 3:16 a.m. OK C++20 (GCC 13-64) TESTS 6 46 0
335229439 AlaaOkasha01 C2 Aug. 24, 2025, 12:18 a.m. OK C++20 (GCC 13-64) TESTS 6 46 0
335224229 RetiredPlayer C2 Aug. 23, 2025, 9:30 p.m. OK C++20 (GCC 13-64) TESTS 6 46 0
335217188 mobakry616 C2 Aug. 23, 2025, 7:40 p.m. OK C++20 (GCC 13-64) TESTS 6 46 0
335196305 GersonVinicius C2 Aug. 23, 2025, 4:42 p.m. OK C++20 (GCC 13-64) TESTS 6 46 0
335184522 Platon_rumilov C2 Aug. 23, 2025, 3:01 p.m. OK C++20 (GCC 13-64) TESTS 6 46 0
335181716 Super.Mario C2 Aug. 23, 2025, 2:38 p.m. OK C++20 (GCC 13-64) TESTS 6 46 0
335179044 linshule C2 Aug. 23, 2025, 2:16 p.m. OK C++20 (GCC 13-64) TESTS 6 46 0
335175387 zhrok C2 Aug. 23, 2025, 1:50 p.m. OK C++20 (GCC 13-64) TESTS 6 46 0
335173953 Tadfo C2 Aug. 23, 2025, 1:39 p.m. OK C++20 (GCC 13-64) TESTS 6 46 0
335178860 Abhinandanporwal C2 Aug. 23, 2025, 2:15 p.m. OK C++23 (GCC 14-64, msys2) TESTS 6 31 0
335053436 Siddharth2020 C2 Aug. 22, 2025, 3:09 p.m. OK C++23 (GCC 14-64, msys2) TESTS 6 31 0
335253307 vissu2603 C2 Aug. 24, 2025, 5:28 a.m. OK C++23 (GCC 14-64, msys2) TESTS 6 46 0
335251286 huynhlanphuong18082004 C2 Aug. 24, 2025, 5:11 a.m. OK C++23 (GCC 14-64, msys2) TESTS 6 46 0
335236514 Hemil_Patel C2 Aug. 24, 2025, 3:48 a.m. OK C++23 (GCC 14-64, msys2) TESTS 6 46 0
335233016 ssz4233 C2 Aug. 24, 2025, 2:22 a.m. OK C++23 (GCC 14-64, msys2) TESTS 6 46 0
335221616 TheTitusAmey C2 Aug. 23, 2025, 8:42 p.m. OK C++23 (GCC 14-64, msys2) TESTS 6 46 0
335220747 Astroage C2 Aug. 23, 2025, 8:29 p.m. OK C++23 (GCC 14-64, msys2) TESTS 6 46 0
335216063 m0RAN C2 Aug. 23, 2025, 7:27 p.m. OK C++23 (GCC 14-64, msys2) TESTS 6 46 0
335215605 Toilet_Paper C2 Aug. 23, 2025, 7:22 p.m. OK C++23 (GCC 14-64, msys2) TESTS 6 46 0
335021464 bhuvan.ch2006 C2 Aug. 22, 2025, 10:54 a.m. OK GNU C11 TESTS 6 93 102400
335222810 ICPCCode C2 Aug. 23, 2025, 9:02 p.m. OK GNU C11 TESTS 6 108 102400
335203595 RS-_- C2 Aug. 23, 2025, 5:38 p.m. OK Java 21 TESTS 6 234 2355200
335151546 Soumarya_Pal C2 Aug. 23, 2025, 10:46 a.m. OK Java 21 TESTS 6 264 614400
335140048 raydon_guo C2 Aug. 23, 2025, 9:19 a.m. OK Java 21 TESTS 6 265 409600
335167984 InfinityX C2 Aug. 23, 2025, 12:54 p.m. OK Java 21 TESTS 6 280 204800
335056412 roushanritik062 C2 Aug. 22, 2025, 3:34 p.m. OK Java 21 TESTS 6 280 512000
335093676 chpkrishnamohan C2 Aug. 22, 2025, 10:40 p.m. OK Java 21 TESTS 6 280 1331200
335051101 mohitmongia2005 C2 Aug. 22, 2025, 2:52 p.m. OK Java 21 TESTS 6 281 204800
335152334 Kakarot_DB C2 Aug. 23, 2025, 10:52 a.m. OK Java 21 TESTS 6 296 102400
335201365 singhdevansh024 C2 Aug. 23, 2025, 5:22 p.m. OK Java 21 TESTS 6 312 102400
335208343 dznz C2 Aug. 23, 2025, 6:13 p.m. OK Java 21 TESTS 6 312 307200
335217591 ishurajora_23 C2 Aug. 23, 2025, 7:45 p.m. OK Java 8 TESTS 6 234 0
335063825 abhayrajnegi0416 C2 Aug. 22, 2025, 4:31 p.m. OK Java 8 TESTS 6 249 0
335123833 jhemanth C2 Aug. 23, 2025, 7:14 a.m. OK Java 8 TESTS 6 296 0
335023681 jatin310 C2 Aug. 22, 2025, 11:15 a.m. OK Java 8 TESTS 6 311 0
335158330 divya8080 C2 Aug. 23, 2025, 11:38 a.m. OK Java 8 TESTS 6 327 0
335078363 only_forward_ C2 Aug. 22, 2025, 6:38 p.m. OK Java 8 TESTS 6 327 0
335120194 harihk24 C2 Aug. 23, 2025, 6:41 a.m. OK Java 8 TESTS 6 343 0
335070905 starboysiddu C2 Aug. 22, 2025, 5:31 p.m. OK Kotlin 1.9 TESTS 6 187 0
335188312 devkowsir C2 Aug. 23, 2025, 3:33 p.m. OK Node.js TESTS 6 280 8601600
335250119 rene25 C2 Aug. 24, 2025, 4:54 a.m. OK Node.js TESTS 6 296 9216000
335080497 karimmalidev C2 Aug. 22, 2025, 7:03 p.m. OK Node.js TESTS 6 311 10342400
335036809 Mr.Beast192 C2 Aug. 22, 2025, 1:10 p.m. OK PyPy 3 TESTS 6 234 6758400
335133159 Prathmesh_H C2 Aug. 23, 2025, 8:30 a.m. OK PyPy 3 TESTS 6 312 7372800
335050326 daminrisho C2 Aug. 22, 2025, 2:46 p.m. OK PyPy 3 TESTS 6 328 6348800
335173911 sathvik_666 C2 Aug. 23, 2025, 1:38 p.m. OK PyPy 3 TESTS 6 1030 11264000
335058716 lucasschnee C2 Aug. 22, 2025, 3:52 p.m. OK PyPy 3-64 TESTS 6 124 3891200
335258351 random738 C2 Aug. 24, 2025, 6:03 a.m. OK PyPy 3-64 TESTS 6 124 4300800
335018896 Om_Singh_ C2 Aug. 22, 2025, 10:28 a.m. OK PyPy 3-64 TESTS 6 140 3891200
335166859 Mandeep_codes C2 Aug. 23, 2025, 12:45 p.m. OK PyPy 3-64 TESTS 6 140 5120000
335160542 OAY71011 C2 Aug. 23, 2025, 11:56 a.m. OK PyPy 3-64 TESTS 6 140 5324800
335024019 Sai_nikhilchakravarthi C2 Aug. 22, 2025, 11:19 a.m. OK PyPy 3-64 TESTS 6 140 8908800
335225528 lucascostaval C2 Aug. 23, 2025, 9:57 p.m. OK PyPy 3-64 TESTS 6 155 3686400
335042578 -98iq C2 Aug. 22, 2025, 1:49 p.m. OK PyPy 3-64 TESTS 6 155 5017600
335044614 manoharsingh2402 C2 Aug. 22, 2025, 2:04 p.m. OK PyPy 3-64 TESTS 6 156 3788800
335127974 young_skywalker_ C2 Aug. 23, 2025, 7:50 a.m. OK PyPy 3-64 TESTS 6 156 8192000
335223606 basicstuff2308 C2 Aug. 23, 2025, 9:17 p.m. OK Python 3 TESTS 6 156 3072000
335223022 basicstuff2308 C2 Aug. 23, 2025, 9:06 p.m. OK Python 3 TESTS 6 156 3072000
335199770 JayeshGadilohar C2 Aug. 23, 2025, 5:09 p.m. OK Python 3 TESTS 6 202 1945600
335056229 bignoseshayan C2 Aug. 22, 2025, 3:32 p.m. OK Python 3 TESTS 6 218 102400
335111250 Flaminthunder C2 Aug. 23, 2025, 5:07 a.m. OK Python 3 TESTS 6 234 204800
335223534 avengers2405 C2 Aug. 23, 2025, 9:16 p.m. OK Python 3 TESTS 6 265 102400
335078984 Velvet_thunder1 C2 Aug. 22, 2025, 6:45 p.m. OK Python 3 TESTS 6 296 409600
335021025 Rcrocks C2 Aug. 22, 2025, 10:50 a.m. OK Python 3 TESTS 6 437 102400
335123011 irahs0104 C2 Aug. 23, 2025, 7:07 a.m. OK Python 3 TESTS 6 593 307200
335174402 Tassad C2 Aug. 23, 2025, 1:42 p.m. OK Rust 2024 TESTS 6 62 0

remove filters

Back to search problems