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"Timur has n candies. The i -th candy has a quantity of sugar equal to a_i . So, by eating the i -th candy, Timur consumes a quantity of sugar equal to a_i . Timur will ask you q queries regarding his candies. For the j -th query you have to answer what is the minimum number of candies he needs to eat in order to reach a quantity of sugar greater than or equal to x_j or print -1 if it's not possible to obtain such a quantity. In other words, you should print the minimum possible k such that after eating k candies, Timur consumes a quantity of sugar of at least x_j or say that no possible k exists. Note that he can't eat the same candy twice and queries are independent of each other (Timur can use the same candy in different queries). The first line of input contains a single integer t ( 1 <= q t <= q 1000 ) -- the number of test cases. The description of test cases follows. The first line contains 2 integers n and q ( 1 <= q n, q <= q 1.5 cdot10^5 ) -- the number of candies Timur has and the number of queries you have to print an answer for respectively. The second line contains n integers a_1, a_2, ... , a_n ( 1 <= q a_i <= q 10^4 ) -- the quantity of sugar in each of the candies respectively. Then q lines follow. Each of the next q lines contains a single integer x_j ( 1 <= q x_j <= q 2 cdot 10^9 ) xe2 x80 x93 the quantity Timur wants to reach for the given query. It is guaranteed that the sum of n and the sum of q over all test cases do not exceed 1.5 cdot 10^5 . For each test case output q lines. For the j -th line output the number of candies Timur needs to eat in order to reach a quantity of sugar greater than or equal to x_j or print -1 if it's not possible to obtain such a quantity. For the first test case: For the first query, Timur can eat any candy, and he will reach the des"... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
156789208 |
bluemegane |
E |
May 11, 2022, 6:59 a.m. |
OK |
C# 8 |
TESTS |
31 |
951 |
17817600 |
|
|
156847033 |
Denor |
E |
May 11, 2022, 3:36 p.m. |
OK |
Delphi |
TESTS |
31 |
139 |
921600 |
|
|
156798686 |
Graythron |
E |
May 11, 2022, 8:55 a.m. |
OK |
GNU C++14 |
TESTS |
31 |
109 |
1536000 |
|
|
156787655 |
zltzlt |
E |
May 11, 2022, 6:41 a.m. |
OK |
GNU C++14 |
TESTS |
31 |
109 |
1638400 |
|
|
156880411 |
TreeTraveler.h |
E |
May 12, 2022, 3:28 a.m. |
OK |
GNU C++14 |
TESTS |
31 |
109 |
2457600 |
|
|
156820023 |
q0000000 |
E |
May 11, 2022, 10:43 a.m. |
OK |
GNU C++14 |
TESTS |
31 |
109 |
2457600 |
|
|
156849102 |
chenjs |
E |
May 11, 2022, 4 p.m. |
OK |
GNU C++14 |
TESTS |
31 |
124 |
614400 |
|
|
156852471 |
chikuiui |
E |
May 11, 2022, 4:42 p.m. |
OK |
GNU C++14 |
TESTS |
31 |
124 |
1228800 |
|
|
156838826 |
mohammad_ruhullah |
E |
May 11, 2022, 1:58 p.m. |
OK |
GNU C++14 |
TESTS |
31 |
124 |
1228800 |
|
|
156788015 |
beep_boop |
E |
May 11, 2022, 6:45 a.m. |
OK |
GNU C++14 |
TESTS |
31 |
124 |
1228800 |
|
|
156823860 |
Canace_HKF |
E |
May 11, 2022, 11:26 a.m. |
OK |
GNU C++14 |
TESTS |
31 |
124 |
1536000 |
|
|
156858220 |
Bohdan309 |
E |
May 11, 2022, 5:59 p.m. |
OK |
GNU C++14 |
TESTS |
31 |
124 |
1638400 |
|
|
156822371 |
Treapen |
E |
May 11, 2022, 11:11 a.m. |
OK |
GNU C++17 |
TESTS |
31 |
78 |
2457600 |
|
|
156818392 |
immaout |
E |
May 11, 2022, 10:24 a.m. |
OK |
GNU C++17 |
TESTS |
31 |
108 |
614400 |
|
|
156843278 |
asda1 |
E |
May 11, 2022, 2:48 p.m. |
OK |
GNU C++17 |
TESTS |
31 |
108 |
1638400 |
|
|
156826191 |
KAUSTUBH152003 |
E |
May 11, 2022, 11:50 a.m. |
OK |
GNU C++17 |
TESTS |
31 |
109 |
614400 |
|
|
156867329 |
JeremyBearimy |
E |
May 11, 2022, 8:25 p.m. |
OK |
GNU C++17 |
TESTS |
31 |
109 |
1228800 |
|
|
156792025 |
Explode_Legacy |
E |
May 11, 2022, 7:35 a.m. |
OK |
GNU C++17 |
TESTS |
31 |
109 |
1843200 |
|
|
156792823 |
laysan |
E |
May 11, 2022, 7:45 a.m. |
OK |
GNU C++17 |
TESTS |
31 |
109 |
3993600 |
|
|
156887741 |
victoriamitsu |
E |
May 12, 2022, 5:55 a.m. |
OK |
GNU C++17 |
TESTS |
31 |
124 |
614400 |
|
|
156838091 |
aman_212 |
E |
May 11, 2022, 1:50 p.m. |
OK |
GNU C++17 |
TESTS |
31 |
124 |
614400 |
|
|
156795426 |
comotbannucute |
E |
May 11, 2022, 8:17 a.m. |
OK |
GNU C++17 |
TESTS |
31 |
124 |
614400 |
|
|
156842469 |
EsmeGod |
E |
May 11, 2022, 2:38 p.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
77 |
614400 |
|
|
156834420 |
NuclearWinter |
E |
May 11, 2022, 1:12 p.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
78 |
614400 |
|
|
156876938 |
Arav_ |
E |
May 12, 2022, 1:51 a.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
78 |
1228800 |
|
|
156876704 |
Arav_ |
E |
May 12, 2022, 1:43 a.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
78 |
1228800 |
|
|
156855731 |
contrust |
E |
May 11, 2022, 5:28 p.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
78 |
1228800 |
|
|
156852617 |
imnasim3.1415 |
E |
May 11, 2022, 4:44 p.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
78 |
1228800 |
|
|
156845219 |
apurba_debnath |
E |
May 11, 2022, 3:13 p.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
78 |
1843200 |
|
|
156833710 |
Meteor_Z |
E |
May 11, 2022, 1:05 p.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
78 |
2457600 |
|
|
156858923 |
bkifhr10 |
E |
May 11, 2022, 6:08 p.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
92 |
1228800 |
|
|
156878476 |
Ziad_Reda |
E |
May 12, 2022, 2:35 a.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
93 |
1228800 |
|
|
156827272 |
ScarletS |
E |
May 11, 2022, 12:01 p.m. |
OK |
GNU C++20 (64) |
TESTS |
31 |
62 |
614400 |
|
|
156876839 |
Fear_less |
E |
May 12, 2022, 1:48 a.m. |
OK |
GNU C++20 (64) |
TESTS |
31 |
62 |
1228800 |
|
|
156855334 |
JackVu |
E |
May 11, 2022, 5:23 p.m. |
OK |
GNU C++20 (64) |
TESTS |
31 |
62 |
1228800 |
|
|
156837450 |
Mazen.Ali |
E |
May 11, 2022, 1:43 p.m. |
OK |
GNU C++20 (64) |
TESTS |
31 |
62 |
1228800 |
|
|
156831305 |
xzzzzz |
E |
May 11, 2022, 12:41 p.m. |
OK |
GNU C++20 (64) |
TESTS |
31 |
62 |
1638400 |
|
|
156831493 |
luogu_bot3 |
E |
May 11, 2022, 12:43 p.m. |
OK |
GNU C++20 (64) |
TESTS |
31 |
62 |
1843200 |
|
|
156788077 |
champion_xD1 |
E |
May 11, 2022, 6:46 a.m. |
OK |
GNU C++20 (64) |
TESTS |
31 |
62 |
2355200 |
|
|
156870897 |
MrM7mD |
E |
May 11, 2022, 9:52 p.m. |
OK |
GNU C++20 (64) |
TESTS |
31 |
62 |
2457600 |
|
|
156795949 |
Gaming |
E |
May 11, 2022, 8:23 a.m. |
OK |
GNU C++20 (64) |
TESTS |
31 |
62 |
2457600 |
|
|
156788007 |
Ahmed_Elhosiny |
E |
May 11, 2022, 6:45 a.m. |
OK |
GNU C++20 (64) |
TESTS |
31 |
62 |
2457600 |
|
|
156874431 |
MunirKP |
E |
May 12, 2022, 12:17 a.m. |
OK |
Java 11 |
TESTS |
31 |
280 |
0 |
|
|
156875671 |
uwuenvy |
E |
May 12, 2022, 1:06 a.m. |
OK |
Java 11 |
TESTS |
31 |
327 |
1536000 |
|
|
156848816 |
garg_lucifer |
E |
May 11, 2022, 3:57 p.m. |
OK |
Java 11 |
TESTS |
31 |
358 |
0 |
|
|
156865436 |
eshan18.09 |
E |
May 11, 2022, 7:48 p.m. |
OK |
Java 11 |
TESTS |
31 |
420 |
2150400 |
|
|
156814335 |
kartheek542 |
E |
May 11, 2022, 9:36 a.m. |
OK |
Java 11 |
TESTS |
31 |
452 |
13619200 |
|
|
156847579 |
Wolfy01 |
E |
May 11, 2022, 3:42 p.m. |
OK |
Java 11 |
TESTS |
31 |
607 |
0 |
|
|
156878917 |
goalboy |
E |
May 12, 2022, 2:47 a.m. |
OK |
Java 11 |
TESTS |
31 |
654 |
11059200 |
|
|
156834219 |
anmol.mact |
E |
May 11, 2022, 1:10 p.m. |
OK |
Java 11 |
TESTS |
31 |
1216 |
0 |
|
|
156832644 |
aiyush007 |
E |
May 11, 2022, 12:54 p.m. |
OK |
Java 11 |
TESTS |
31 |
1216 |
0 |
|
|
156838439 |
Prateek_Jakhar |
E |
May 11, 2022, 1:54 p.m. |
OK |
Java 11 |
TESTS |
31 |
1263 |
0 |
|
|
156880979 |
Zahid_Hasan_Sahin |
E |
May 12, 2022, 3:40 a.m. |
OK |
Java 8 |
TESTS |
31 |
217 |
0 |
|
|
156855410 |
abdoad941 |
E |
May 11, 2022, 5:24 p.m. |
OK |
Java 8 |
TESTS |
31 |
218 |
0 |
|
|
156840412 |
sharpen |
E |
May 11, 2022, 2:15 p.m. |
OK |
Java 8 |
TESTS |
31 |
218 |
0 |
|
|
156820103 |
Ahmed_yehia_hosny |
E |
May 11, 2022, 10:44 a.m. |
OK |
Java 8 |
TESTS |
31 |
218 |
0 |
|
|
156839366 |
Youssef1Shawky |
E |
May 11, 2022, 2:04 p.m. |
OK |
Java 8 |
TESTS |
31 |
264 |
0 |
|
|
156878365 |
wangks |
E |
May 12, 2022, 2:32 a.m. |
OK |
Java 8 |
TESTS |
31 |
265 |
0 |
|
|
156829441 |
akshaykumar200042 |
E |
May 11, 2022, 12:23 p.m. |
OK |
Java 8 |
TESTS |
31 |
265 |
0 |
|
|
156843369 |
nithin_bharathi |
E |
May 11, 2022, 2:49 p.m. |
OK |
Java 8 |
TESTS |
31 |
265 |
8601600 |
|
|
156795289 |
ttolkku |
E |
May 11, 2022, 8:16 a.m. |
OK |
Java 8 |
TESTS |
31 |
296 |
0 |
|
|
156790247 |
pandeyjii_11 |
E |
May 11, 2022, 7:12 a.m. |
OK |
Java 8 |
TESTS |
31 |
327 |
102400 |
|
|
156848492 |
Krantzy |
E |
May 11, 2022, 3:53 p.m. |
OK |
Kotlin 1.6 |
TESTS |
31 |
1357 |
9728000 |
|
|
156842810 |
bhdtr |
E |
May 11, 2022, 2:42 p.m. |
OK |
MS C++ 2017 |
TESTS |
31 |
124 |
11980800 |
|
|
156825797 |
Superlau |
E |
May 11, 2022, 11:46 a.m. |
OK |
MS C++ 2017 |
TESTS |
31 |
156 |
2457600 |
|
|
156864893 |
Still_Theory |
E |
May 11, 2022, 7:39 p.m. |
OK |
MS C++ 2017 |
TESTS |
31 |
390 |
1228800 |
|
|
156849835 |
lyg3715371537 |
E |
May 11, 2022, 4:09 p.m. |
OK |
MS C++ 2017 |
TESTS |
31 |
794 |
2457600 |
|
|
156842126 |
bhdtr |
E |
May 11, 2022, 2:34 p.m. |
OK |
MS C++ 2017 |
TESTS |
31 |
795 |
1228800 |
|
|
156794867 |
EgorSav |
E |
May 11, 2022, 8:10 a.m. |
OK |
MS C++ 2017 |
TESTS |
31 |
810 |
819200 |
|
|
156849495 |
digjoynandi12 |
E |
May 11, 2022, 4:05 p.m. |
OK |
MS C++ 2017 |
TESTS |
31 |
826 |
1228800 |
|
|
156821076 |
abychkou |
E |
May 11, 2022, 10:56 a.m. |
OK |
MS C++ 2017 |
TESTS |
31 |
826 |
1228800 |
|
|
156856596 |
Tangerine |
E |
May 11, 2022, 5:39 p.m. |
OK |
MS C++ 2017 |
TESTS |
31 |
826 |
2457600 |
|
|
156796732 |
KarimShebl003 |
E |
May 11, 2022, 8:32 a.m. |
OK |
MS C++ 2017 |
TESTS |
31 |
889 |
1228800 |
|
|
156801091 |
XYShaoKang |
E |
May 11, 2022, 9:24 a.m. |
OK |
Node.js |
TESTS |
31 |
530 |
39424000 |
|
|
156882631 |
yoralbayev |
E |
May 12, 2022, 4:17 a.m. |
OK |
PHP |
TESTS |
31 |
2776 |
43520000 |
|
|
156843811 |
MrDrogon |
E |
May 11, 2022, 2:55 p.m. |
OK |
PyPy 3 |
TESTS |
31 |
233 |
19456000 |
|
|
156825319 |
NAVI_Perfecto |
E |
May 11, 2022, 11:41 a.m. |
OK |
PyPy 3 |
TESTS |
31 |
420 |
21196800 |
|
|
156855674 |
worldsaver |
E |
May 11, 2022, 5:27 p.m. |
OK |
PyPy 3 |
TESTS |
31 |
483 |
15360000 |
|
|
156822686 |
kamtendra_20 |
E |
May 11, 2022, 11:14 a.m. |
OK |
PyPy 3 |
TESTS |
31 |
514 |
15257600 |
|
|
156854347 |
ambs_ |
E |
May 11, 2022, 5:08 p.m. |
OK |
PyPy 3 |
TESTS |
31 |
529 |
15257600 |
|
|
156826901 |
kojihashimoto |
E |
May 11, 2022, 11:57 a.m. |
OK |
PyPy 3 |
TESTS |
31 |
1700 |
14336000 |
|
|
156884797 |
quangltfsc0378 |
E |
May 12, 2022, 5:02 a.m. |
OK |
PyPy 3 |
TESTS |
31 |
1996 |
14950400 |
|
|
156838535 |
Driver12 |
E |
May 11, 2022, 1:55 p.m. |
OK |
PyPy 3 |
TESTS |
31 |
2027 |
16896000 |
|
|
156874868 |
ttorpy |
E |
May 12, 2022, 12:36 a.m. |
OK |
PyPy 3 |
TESTS |
31 |
2043 |
15052800 |
|
|
156854864 |
ShrijitShaswat |
E |
May 11, 2022, 5:16 p.m. |
OK |
PyPy 3 |
TESTS |
31 |
2308 |
27443200 |
|
|
156814157 |
Maximilian06 |
E |
May 11, 2022, 9:34 a.m. |
OK |
PyPy 3-64 |
TESTS |
31 |
248 |
26419200 |
|
|
156788542 |
Night_Spark--75 |
E |
May 11, 2022, 6:51 a.m. |
OK |
PyPy 3-64 |
TESTS |
31 |
249 |
29081600 |
|
|
156854923 |
notTehlka |
E |
May 11, 2022, 5:17 p.m. |
OK |
PyPy 3-64 |
TESTS |
31 |
264 |
21913600 |
|
|
156848451 |
snape_here |
E |
May 11, 2022, 3:52 p.m. |
OK |
PyPy 3-64 |
TESTS |
31 |
421 |
41779200 |
|
|
156819543 |
jainmilind |
E |
May 11, 2022, 10:37 a.m. |
OK |
PyPy 3-64 |
TESTS |
31 |
436 |
24473600 |
|
|
156798654 |
iron_nicko |
E |
May 11, 2022, 8:55 a.m. |
OK |
PyPy 3-64 |
TESTS |
31 |
467 |
19251200 |
|
|
156819248 |
jainmilind |
E |
May 11, 2022, 10:34 a.m. |
OK |
PyPy 3-64 |
TESTS |
31 |
483 |
23961600 |
|
|
156819327 |
jainmilind |
E |
May 11, 2022, 10:34 a.m. |
OK |
PyPy 3-64 |
TESTS |
31 |
498 |
24268800 |
|
|
156824459 |
Invinc3 |
E |
May 11, 2022, 11:33 a.m. |
OK |
PyPy 3-64 |
TESTS |
31 |
514 |
20787200 |
|
|
156868974 |
MistaAsh |
E |
May 11, 2022, 8:59 p.m. |
OK |
PyPy 3-64 |
TESTS |
31 |
514 |
23244800 |
|
|
156862162 |
mvb35 |
E |
May 11, 2022, 6:54 p.m. |
OK |
Python 3 |
TESTS |
31 |
608 |
10649600 |
|
|
156885126 |
Rainmaker2627 |
E |
May 12, 2022, 5:09 a.m. |
OK |
Python 3 |
TESTS |
31 |
670 |
10854400 |
|
|
156886527 |
psycho_pirate |
E |
May 12, 2022, 5:34 a.m. |
OK |
Python 3 |
TESTS |
31 |
1294 |
10854400 |
|
|
156822075 |
adityadubey450 |
E |
May 11, 2022, 11:08 a.m. |
OK |
Python 3 |
TESTS |
31 |
1403 |
10649600 |
|
|
156814439 |
Tanguyvans |
E |
May 11, 2022, 9:38 a.m. |
OK |
Python 3 |
TESTS |
31 |
1403 |
10649600 |
|
|
156814611 |
rr745 |
E |
May 11, 2022, 9:40 a.m. |
OK |
Python 3 |
TESTS |
31 |
1419 |
10649600 |
|
|
156827907 |
chemistry_guy |
E |
May 11, 2022, 12:07 p.m. |
OK |
Python 3 |
TESTS |
31 |
1434 |
10956800 |
|
|
156875691 |
wzqqqqq |
E |
May 12, 2022, 1:07 a.m. |
OK |
Python 3 |
TESTS |
31 |
1450 |
10649600 |
|
|
156786911 |
KK_1729 |
E |
May 11, 2022, 6:33 a.m. |
OK |
Python 3 |
TESTS |
31 |
1528 |
10649600 |
|
|
156859447 |
WhyAsh5114 |
E |
May 11, 2022, 6:15 p.m. |
OK |
Python 3 |
TESTS |
31 |
1762 |
10956800 |
|
|
remove filters
Back to search problems