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.
Problems
B"Monocarp is going to make a purchase with cost of exactly m burles. He has two types of coins, in the following quantities: Monocarp wants to make his purchase in such a way that there's no change -- the total worth of provided coins is exactly m . He can use both regular and fancy coins. However, he wants to spend as little fancy coins as possible. What's the smallest total number of fancy coins he can use to make a purchase? The first line contains a single integer t ( 1 <= t <= 3 cdot 10^4 ) -- the number of testcases. The only line of each testcase contains four integers m, k, a_1 and a_k ( 1 <= m <= 10^8 ; 2 <= k <= 10^8 ; 0 <= a_1, a_k <= 10^8 ) -- the cost of the purchase, the worth of the second type of coin and the amounts of regular coins of both types, respectively. For each testcase, print a single integer -- the smallest total number of fancy coins Monocarp can use to make a purchase. In the first testcase, there are no regular coins of either type. Monocarp can use 2 fancy coins worth 1 burle and 3 fancy coins worth 3 (since k=3 ) burles to get 11 total burles with 5 total fancy coins. In the second testcase, Monocarp has a lot of regular coins of both types. He can use 11 regular coins worth 1 burle, for example. Notice that Monocarp doesn't have to minimize the total number of used coins. That way he uses 0 fancy coins. In the third testcase, Monocarp can use 5 regular coins worth 1 burle and 1 regular coin worth 3 burles. That will get him to 8 total burles when he needs 11 . So, 1 fancy coin worth 3 burles is enough. "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
219379714 |
Buki |
B |
Aug. 17, 2023, 10:44 p.m. |
OK |
C# 10 |
TESTS |
5 |
46 |
5222400 |
|
|
219352267 |
Baga_Boom |
B |
Aug. 17, 2023, 5:10 p.m. |
OK |
C# 10 |
TESTS |
5 |
233 |
3174400 |
|
|
219397559 |
bluemegane |
B |
Aug. 18, 2023, 4:32 a.m. |
OK |
C# 8 |
TESTS |
5 |
249 |
3481600 |
|
|
219372736 |
greasyfinger |
B |
Aug. 17, 2023, 8:41 p.m. |
OK |
Clang++17 Diagnostics |
TESTS |
5 |
748 |
0 |
|
|
219372414 |
greasyfinger |
B |
Aug. 17, 2023, 8:36 p.m. |
OK |
Clang++17 Diagnostics |
TESTS |
5 |
779 |
0 |
|
|
219371870 |
NenadDapic |
B |
Aug. 17, 2023, 8:28 p.m. |
OK |
FPC |
TESTS |
5 |
124 |
102400 |
|
|
219362760 |
DarkWillow |
B |
Aug. 17, 2023, 6:36 p.m. |
OK |
GNU C11 |
TESTS |
5 |
31 |
0 |
|
|
219375708 |
sachinkr1912s |
B |
Aug. 17, 2023, 9:09 p.m. |
OK |
GNU C11 |
TESTS |
5 |
140 |
0 |
|
|
219354212 |
anonymuspj |
B |
Aug. 17, 2023, 5:23 p.m. |
OK |
GNU C11 |
TESTS |
5 |
156 |
0 |
|
|
219362782 |
WASIF_74 |
B |
Aug. 17, 2023, 6:36 p.m. |
OK |
GNU C11 |
TESTS |
5 |
265 |
0 |
|
|
219362676 |
WASIF_74 |
B |
Aug. 17, 2023, 6:35 p.m. |
OK |
GNU C11 |
TESTS |
5 |
265 |
0 |
|
|
219349136 |
keshav15104 |
B |
Aug. 17, 2023, 4:52 p.m. |
OK |
GNU C11 |
TESTS |
5 |
280 |
0 |
|
|
219347178 |
fuxuantong123 |
B |
Aug. 17, 2023, 4:43 p.m. |
OK |
GNU C++14 |
TESTS |
5 |
30 |
0 |
|
|
219363843 |
TheTennisPlayer |
B |
Aug. 17, 2023, 6:48 p.m. |
OK |
GNU C++14 |
TESTS |
5 |
31 |
0 |
|
|
219360495 |
Crsuh2er0 |
B |
Aug. 17, 2023, 6:15 p.m. |
OK |
GNU C++14 |
TESTS |
5 |
31 |
0 |
|
|
219352928 |
lksible |
B |
Aug. 17, 2023, 5:14 p.m. |
OK |
GNU C++14 |
TESTS |
5 |
31 |
0 |
|
|
219385500 |
zhyj |
B |
Aug. 18, 2023, 1:20 a.m. |
OK |
GNU C++14 |
TESTS |
5 |
31 |
0 |
|
|
219366940 |
omeganot |
B |
Aug. 17, 2023, 7:22 p.m. |
OK |
GNU C++14 |
TESTS |
5 |
31 |
0 |
|
|
219391738 |
xiaoalier_fan |
B |
Aug. 18, 2023, 3:07 a.m. |
OK |
GNU C++14 |
TESTS |
5 |
31 |
0 |
|
|
219399418 |
aCssen |
B |
Aug. 18, 2023, 4:57 a.m. |
OK |
GNU C++14 |
TESTS |
5 |
31 |
0 |
|
|
219404163 |
Bai_xiaobo |
B |
Aug. 18, 2023, 5:55 a.m. |
OK |
GNU C++14 |
TESTS |
5 |
31 |
0 |
|
|
219386661 |
mwienig |
B |
Aug. 18, 2023, 1:42 a.m. |
OK |
GNU C++14 |
TESTS |
5 |
31 |
0 |
|
|
219391205 |
xglixzk |
B |
Aug. 18, 2023, 2:59 a.m. |
OK |
GNU C++17 |
TESTS |
5 |
30 |
0 |
|
|
219390784 |
muhammed_222 |
B |
Aug. 18, 2023, 2:52 a.m. |
OK |
GNU C++17 |
TESTS |
5 |
31 |
0 |
|
|
219388844 |
wajiul |
B |
Aug. 18, 2023, 2:20 a.m. |
OK |
GNU C++17 |
TESTS |
5 |
31 |
0 |
|
|
219385958 |
Victor.cpp |
B |
Aug. 18, 2023, 1:29 a.m. |
OK |
GNU C++17 |
TESTS |
5 |
31 |
0 |
|
|
219403536 |
pinku_codes |
B |
Aug. 18, 2023, 5:47 a.m. |
OK |
GNU C++17 |
TESTS |
5 |
31 |
0 |
|
|
219399824 |
noobcoder31 |
B |
Aug. 18, 2023, 5:02 a.m. |
OK |
GNU C++17 |
TESTS |
5 |
31 |
0 |
|
|
219398509 |
1_Hypex_ |
B |
Aug. 18, 2023, 4:45 a.m. |
OK |
GNU C++17 |
TESTS |
5 |
31 |
0 |
|
|
219396864 |
suyasho786 |
B |
Aug. 18, 2023, 4:22 a.m. |
OK |
GNU C++17 |
TESTS |
5 |
31 |
0 |
|
|
219391170 |
sourav_suku |
B |
Aug. 18, 2023, 2:58 a.m. |
OK |
GNU C++17 |
TESTS |
5 |
31 |
0 |
|
|
219394963 |
Tourist_Jr |
B |
Aug. 18, 2023, 3:54 a.m. |
OK |
GNU C++17 |
TESTS |
5 |
31 |
0 |
|
|
219376036 |
comingsoon.cpp |
B |
Aug. 17, 2023, 9:15 p.m. |
OK |
GNU C++17 (64) |
TESTS |
5 |
15 |
0 |
|
|
219386558 |
shuvocoder2025 |
B |
Aug. 18, 2023, 1:40 a.m. |
OK |
GNU C++17 (64) |
TESTS |
5 |
15 |
0 |
|
|
219348881 |
ducminh2004pd |
B |
Aug. 17, 2023, 4:51 p.m. |
OK |
GNU C++17 (64) |
TESTS |
5 |
15 |
0 |
|
|
219342732 |
abood03 |
B |
Aug. 17, 2023, 4:33 p.m. |
OK |
GNU C++17 (64) |
TESTS |
5 |
15 |
0 |
|
|
219349828 |
Deshik |
B |
Aug. 17, 2023, 4:56 p.m. |
OK |
GNU C++17 (64) |
TESTS |
5 |
30 |
0 |
|
|
219352055 |
Mahfuj_SUST |
B |
Aug. 17, 2023, 5:08 p.m. |
OK |
GNU C++17 (64) |
TESTS |
5 |
30 |
0 |
|
|
219384140 |
jk1024 |
B |
Aug. 18, 2023, 12:52 a.m. |
OK |
GNU C++17 (64) |
TESTS |
5 |
30 |
0 |
|
|
219384189 |
rumman_sust |
B |
Aug. 18, 2023, 12:54 a.m. |
OK |
GNU C++17 (64) |
TESTS |
5 |
30 |
0 |
|
|
219384255 |
Ashlyn |
B |
Aug. 18, 2023, 12:55 a.m. |
OK |
GNU C++17 (64) |
TESTS |
5 |
30 |
0 |
|
|
219387485 |
200389 |
B |
Aug. 18, 2023, 1:55 a.m. |
OK |
GNU C++17 (64) |
TESTS |
5 |
30 |
0 |
|
|
219398004 |
waku111 |
B |
Aug. 18, 2023, 4:38 a.m. |
OK |
GNU C++20 (64) |
TESTS |
5 |
15 |
0 |
|
|
219397157 |
coderpy_04 |
B |
Aug. 18, 2023, 4:26 a.m. |
OK |
GNU C++20 (64) |
TESTS |
5 |
15 |
0 |
|
|
219396873 |
wacko |
B |
Aug. 18, 2023, 4:22 a.m. |
OK |
GNU C++20 (64) |
TESTS |
5 |
15 |
0 |
|
|
219395087 |
ppnoonbb |
B |
Aug. 18, 2023, 3:55 a.m. |
OK |
GNU C++20 (64) |
TESTS |
5 |
15 |
0 |
|
|
219402078 |
Hasnat0006 |
B |
Aug. 18, 2023, 5:30 a.m. |
OK |
GNU C++20 (64) |
TESTS |
5 |
15 |
0 |
|
|
219402020 |
Sourav.Kumar007 |
B |
Aug. 18, 2023, 5:29 a.m. |
OK |
GNU C++20 (64) |
TESTS |
5 |
15 |
0 |
|
|
219401500 |
rawatkunal31 |
B |
Aug. 18, 2023, 5:23 a.m. |
OK |
GNU C++20 (64) |
TESTS |
5 |
15 |
0 |
|
|
219399405 |
Danyaaaaaaaa1 |
B |
Aug. 18, 2023, 4:57 a.m. |
OK |
GNU C++20 (64) |
TESTS |
5 |
15 |
0 |
|
|
219399351 |
Danyaaaaaaaa1 |
B |
Aug. 18, 2023, 4:56 a.m. |
OK |
GNU C++20 (64) |
TESTS |
5 |
15 |
0 |
|
|
219398051 |
ayush_n |
B |
Aug. 18, 2023, 4:39 a.m. |
OK |
GNU C++20 (64) |
TESTS |
5 |
15 |
0 |
|
|
219352952 |
sunaj |
B |
Aug. 17, 2023, 5:14 p.m. |
OK |
Java 11 |
TESTS |
5 |
187 |
0 |
|
|
219349572 |
polsage |
B |
Aug. 17, 2023, 4:54 p.m. |
OK |
Java 11 |
TESTS |
5 |
327 |
0 |
|
|
219359894 |
prac_123 |
B |
Aug. 17, 2023, 6:10 p.m. |
OK |
Java 11 |
TESTS |
5 |
343 |
0 |
|
|
219375874 |
Harwinvanak |
B |
Aug. 17, 2023, 9:12 p.m. |
OK |
Java 11 |
TESTS |
5 |
373 |
0 |
|
|
219371908 |
Harwinvanak |
B |
Aug. 17, 2023, 8:28 p.m. |
OK |
Java 11 |
TESTS |
5 |
405 |
0 |
|
|
219390797 |
Vivek8877 |
B |
Aug. 18, 2023, 2:53 a.m. |
OK |
Java 11 |
TESTS |
5 |
530 |
0 |
|
|
219349604 |
ar_ag |
B |
Aug. 17, 2023, 4:55 p.m. |
OK |
Java 11 |
TESTS |
5 |
545 |
0 |
|
|
219344351 |
flicktoss |
B |
Aug. 17, 2023, 4:34 p.m. |
OK |
Java 17 |
TESTS |
5 |
202 |
512000 |
|
|
219401408 |
jiangqiao |
B |
Aug. 18, 2023, 5:22 a.m. |
OK |
Java 17 |
TESTS |
5 |
217 |
512000 |
|
|
219346768 |
daksh_02 |
B |
Aug. 17, 2023, 4:41 p.m. |
OK |
Java 17 |
TESTS |
5 |
218 |
512000 |
|
|
219349408 |
ahmed.elbakly |
B |
Aug. 17, 2023, 4:53 p.m. |
OK |
Java 17 |
TESTS |
5 |
233 |
204800 |
|
|
219400910 |
ayush141 |
B |
Aug. 18, 2023, 5:15 a.m. |
OK |
Java 17 |
TESTS |
5 |
233 |
716800 |
|
|
219359201 |
sergey.chistofor |
B |
Aug. 17, 2023, 6:04 p.m. |
OK |
Java 17 |
TESTS |
5 |
234 |
614400 |
|
|
219384748 |
chenxiaoming |
B |
Aug. 18, 2023, 1:06 a.m. |
OK |
Java 17 |
TESTS |
5 |
265 |
102400 |
|
|
219363654 |
AKhacks |
B |
Aug. 17, 2023, 6:46 p.m. |
OK |
Java 17 |
TESTS |
5 |
265 |
204800 |
|
|
219371119 |
Pren |
B |
Aug. 17, 2023, 8:17 p.m. |
OK |
Java 17 |
TESTS |
5 |
296 |
409600 |
|
|
219381904 |
aris_sk |
B |
Aug. 17, 2023, 11:51 p.m. |
OK |
Java 17 |
TESTS |
5 |
342 |
512000 |
|
|
219385975 |
leonlian |
B |
Aug. 18, 2023, 1:29 a.m. |
OK |
Java 8 |
TESTS |
5 |
93 |
0 |
|
|
219383830 |
yadavDipesh |
B |
Aug. 18, 2023, 12:45 a.m. |
OK |
Java 8 |
TESTS |
5 |
93 |
0 |
|
|
219383166 |
yadavDipesh |
B |
Aug. 18, 2023, 12:27 a.m. |
OK |
Java 8 |
TESTS |
5 |
93 |
0 |
|
|
219397899 |
yousef03 |
B |
Aug. 18, 2023, 4:37 a.m. |
OK |
Java 8 |
TESTS |
5 |
109 |
0 |
|
|
219350016 |
_Demonizer_ |
B |
Aug. 17, 2023, 4:57 p.m. |
OK |
Java 8 |
TESTS |
5 |
124 |
0 |
|
|
219398704 |
goku_peng |
B |
Aug. 18, 2023, 4:48 a.m. |
OK |
Java 8 |
TESTS |
5 |
296 |
0 |
|
|
219370479 |
Sumitsingh7 |
B |
Aug. 17, 2023, 8:08 p.m. |
OK |
Java 8 |
TESTS |
5 |
296 |
7475200 |
|
|
219371574 |
hamossa |
B |
Aug. 17, 2023, 8:23 p.m. |
OK |
Java 8 |
TESTS |
5 |
311 |
0 |
|
|
219353419 |
Tomatos03 |
B |
Aug. 17, 2023, 5:17 p.m. |
OK |
Java 8 |
TESTS |
5 |
326 |
0 |
|
|
219352042 |
Tomatos03 |
B |
Aug. 17, 2023, 5:08 p.m. |
OK |
Java 8 |
TESTS |
5 |
326 |
0 |
|
|
219355916 |
tatianyi |
B |
Aug. 17, 2023, 5:36 p.m. |
OK |
MS C++ 2017 |
TESTS |
5 |
140 |
0 |
|
|
219342838 |
RSL459 |
B |
Aug. 17, 2023, 4:33 p.m. |
OK |
MS C++ 2017 |
TESTS |
5 |
202 |
0 |
|
|
219343231 |
Pritamofficial |
B |
Aug. 17, 2023, 4:33 p.m. |
OK |
MS C++ 2017 |
TESTS |
5 |
233 |
0 |
|
|
219344134 |
akshatagrawal4 |
B |
Aug. 17, 2023, 4:34 p.m. |
OK |
MS C++ 2017 |
TESTS |
5 |
234 |
0 |
|
|
219367160 |
SlayerS |
B |
Aug. 17, 2023, 7:24 p.m. |
OK |
Node.js |
TESTS |
5 |
265 |
7475200 |
|
|
219375118 |
osato |
B |
Aug. 17, 2023, 8:58 p.m. |
OK |
Node.js |
TESTS |
5 |
343 |
6553600 |
|
|
219345327 |
aviral311 |
B |
Aug. 17, 2023, 4:37 p.m. |
OK |
PyPy 3 |
TESTS |
5 |
202 |
7065600 |
|
|
219349917 |
lucasg05 |
B |
Aug. 17, 2023, 4:56 p.m. |
OK |
PyPy 3 |
TESTS |
5 |
592 |
8089600 |
|
|
219398986 |
Youarenotgood |
B |
Aug. 18, 2023, 4:51 a.m. |
OK |
PyPy 3-64 |
TESTS |
5 |
108 |
9216000 |
|
|
219392779 |
9.86960440109 |
B |
Aug. 18, 2023, 3:22 a.m. |
OK |
PyPy 3-64 |
TESTS |
5 |
139 |
9523200 |
|
|
219362417 |
Yash_Nandwana |
B |
Aug. 17, 2023, 6:32 p.m. |
OK |
PyPy 3-64 |
TESTS |
5 |
139 |
9830400 |
|
|
219353621 |
xiej |
B |
Aug. 17, 2023, 5:18 p.m. |
OK |
PyPy 3-64 |
TESTS |
5 |
139 |
10444800 |
|
|
219396591 |
tnv2004 |
B |
Aug. 18, 2023, 4:18 a.m. |
OK |
PyPy 3-64 |
TESTS |
5 |
140 |
9625600 |
|
|
219351548 |
tnv2004 |
B |
Aug. 17, 2023, 5:05 p.m. |
OK |
PyPy 3-64 |
TESTS |
5 |
140 |
9625600 |
|
|
219348803 |
gardengnome |
B |
Aug. 17, 2023, 4:51 p.m. |
OK |
PyPy 3-64 |
TESTS |
5 |
140 |
9625600 |
|
|
219352847 |
khalit7 |
B |
Aug. 17, 2023, 5:13 p.m. |
OK |
PyPy 3-64 |
TESTS |
5 |
140 |
10137600 |
|
|
219396569 |
tnv2004 |
B |
Aug. 18, 2023, 4:18 a.m. |
OK |
PyPy 3-64 |
TESTS |
5 |
155 |
9318400 |
|
|
219345562 |
deepansh09 |
B |
Aug. 17, 2023, 4:37 p.m. |
OK |
PyPy 3-64 |
TESTS |
5 |
155 |
9523200 |
|
|
219369785 |
alexpods |
B |
Aug. 17, 2023, 7:58 p.m. |
OK |
Python 3 |
TESTS |
5 |
93 |
2867200 |
|
|
219404589 |
eugalt |
B |
Aug. 18, 2023, 6 a.m. |
OK |
Python 3 |
TESTS |
5 |
108 |
3481600 |
|
|
219402781 |
eugalt |
B |
Aug. 18, 2023, 5:38 a.m. |
OK |
Python 3 |
TESTS |
5 |
108 |
3481600 |
|
|
219362038 |
layzer |
B |
Aug. 17, 2023, 6:28 p.m. |
OK |
Python 3 |
TESTS |
5 |
109 |
307200 |
|
|
219380419 |
ravikumarO |
B |
Aug. 17, 2023, 11:03 p.m. |
OK |
Python 3 |
TESTS |
5 |
124 |
1228800 |
|
|
219403361 |
eugalt |
B |
Aug. 18, 2023, 5:45 a.m. |
OK |
Python 3 |
TESTS |
5 |
124 |
3481600 |
|
|
219401874 |
eugalt |
B |
Aug. 18, 2023, 5:28 a.m. |
OK |
Python 3 |
TESTS |
5 |
124 |
3481600 |
|
|
219387224 |
Trainer_Marvin |
B |
Aug. 18, 2023, 1:51 a.m. |
OK |
Python 3 |
TESTS |
5 |
140 |
1433600 |
|
|
219400046 |
uttamkumarreddy123 |
B |
Aug. 18, 2023, 5:04 a.m. |
OK |
Python 3 |
TESTS |
5 |
248 |
0 |
|
|
219346435 |
pavvv_36 |
B |
Aug. 17, 2023, 4:40 p.m. |
OK |
Python 3 |
TESTS |
5 |
248 |
0 |
|
|
219400715 |
kiddoos |
B |
Aug. 18, 2023, 5:13 a.m. |
OK |
Rust 2021 |
TESTS |
5 |
233 |
0 |
|
|
219383732 |
AkagiYuu |
B |
Aug. 18, 2023, 12:43 a.m. |
OK |
Rust 2021 |
TESTS |
5 |
295 |
0 |
|
|
219384000 |
ilyshana |
B |
Aug. 18, 2023, 12:49 a.m. |
OK |
Rust 2021 |
TESTS |
5 |
420 |
0 |
|
|
remove filters
Back to search problems