Magical Candies

0

0 votes
Binary Search
Problem

There is a magical candy box in which it gives some random number of candies every day.But after N days its magical power will be lost. So you can collect  some random number of candies  everyday for N days.

Now you will be  asked Q queries. In each query you have to answer number of days it took  to collect M number of candies.

INPUT :

First line of test case contains N denoting number of days.

Next line there will be N space seperated integers denoting Number of candies you get each day.

Next line contains Q dentoing number of queries and next q lines followed by M .

OUTPUT :

For each of the Q queries, you have to output the number of days taken to collect number of candies in a new line.

CONSTRAINTS :

1<=N,Q<=5105

1<=a[i]<=105

1<=M<=sumofcandies

Sample Input
5
1 2 3 4 5
4
3
8
10
14
Sample Output
2
4
4
5
Time Limit: 1
Memory Limit: 256
Source Limit:
Contributers:
Editor Image

?