DCP-318: Sanvi and chocolates Back to All Problems

Medium Data Structures > Basic Data Structures

**Sanvi** is a very cute girl. She likes chocolates so much. She has built a robot which provides her some amount of chocolates everyday. The robot operates **D** days consecutively. Everyday, It provides some amount of chocolates to Sanvi. You are given **Q** wishlist of Sanvi. Your task is to process her **Q** wishes. Every wish contain an integer denoting the total number of chocolates she wants to eat -**Y**. You have to find the total number of days required to fulfill her wish.Her wish will be fulfilled if she could get chocolates greater than or equal to **Y**. ***Note: Time limit is too tight. Naive solution will not pass within the time limit.*** Input: ------ Input starts with an integer **T (1<=T<=15)**, denoting the number of test cases. Each case starts with two integers **D,Q** as described in the problem statement. Then there will be a line with space separated **D** integers denoting amount of chocolate robot provide in each day( ***Ci*** ). Finally, There will be **Q** more lines with a integer ( ***Yi*** ) denoting amount of chocolate she wants to eat. Constraint: ------- **1<=D,Q,Ci,Yi<=10^5.** Output: ------- For every **Q** wishes output a line of output denoting total number of days required to fulfill that wish. If it is not possible to fulfill that wish, output **-1** instead. Sample Input ------------ 1 5 4 3 5 3 6 5 1 4 17 33 Sample Output ------------- 1 2 4 -1

Problem Setter:

Bishal Gautam

Please login to submit solution to this problem.

Problem Limits

Language Time Limit (seconds)
C 0.50
C++ 0.50
C++14 0.50
C# 0.80
Go 0.80
Java 0.80
JavaScript 0.80
Objective-C 0.80
Perl 0.80
PHP 1.00
Python 0.80
Python3 0.80
Ruby 0.80
VB.Net 0.80

Problem Stats




# User Language Timing
01 feodorv Cpp14 0.18s
02 Morass Cpp14 0.18s
03 prateepm Cpp14 0.19s
04 Sarwar05 Cpp 0.29s
05 khatribiru Cpp14 0.30s
06 PKP_007 Cpp14 0.31s
07 prottoy919 Cpp14 0.31s
08 rubabredwan Cpp14 0.33s
09 alif_biswas Cpp14 0.35s
10 Robbinb1993 Cpp14 0.35s
11 ____ Cpp14 0.36s
12 Double_O Cpp14 0.38s
13 humayan7711 Cpp14 0.38s
14 jahid_ict Cpp14 0.38s
15 shihabsarar29 Cpp14 0.39s
16 njrafi Cpp14 0.39s
17 fsshakkhor Cpp14 0.39s
18 sahedsohel Cpp14 0.39s
19 mtmohim Cpp14 0.39s
20 Tanmoy Cpp14 0.39s
21 Emdadul_Hoque Cpp14 0.39s
22 ekayesorko Cpp14 0.39s
23 Taran Cpp14 0.40s
24 Islam_Rafat Cpp14 0.40s
25 alhelal_cse Cpp14 0.40s
26 shahedjamil108 Cpp14 0.40s
27 SakibAlamin Cpp14 0.40s
28 yakin Cpp14 0.40s
29 pulak_ict_mbstu Cpp14 0.40s
30 sumon23 Cpp14 0.40s
31 seyedssz Cpp14 0.40s
32 sohelcseiu Cpp14 0.40s
33 flash_7 Cpp14 0.40s
34 imAnik Cpp14 0.40s
35 skmonir Cpp14 0.40s
36 Protap_Ghose Cpp14 0.40s
37 fuad_ahmed Cpp14 0.40s
38 saiful130104 Cpp14 0.40s
39 emrul Cpp14 0.40s
40 nahid08 Cpp14 0.40s
41 Pure_Protea Cpp14 0.40s
42 astrolion7 Cpp14 0.40s
43 mamun4122 Cpp14 0.40s
44 Jobayer__ Cpp14 0.40s
45 subhashis_cse Cpp14 0.40s
46 nurshuvo51 Cpp14 0.41s
47 rayhan50001 Cpp14 0.41s
48 ssavi Cpp14 0.41s
49 anikatahsin Cpp14 0.41s
50 nuhu_iu Cpp14 0.41s

Your feedback is our precious!

Or call +88 02 9853138 for support