All Tracks Algorithms Searching Binary Search Problem

Stone's Love
Tag(s):

Easy

Problem
Editorial
Analytics

Senorita likes stones very much. As she is fond of collecting beautiful stones, everyday she finds some of the stones beautiful and collects it in her bottle.

You are given the number of stones, she collects each day for N numbers of days, starting from the very first day. Now you are given Q queries, in each query her friend shambhavi asks you the number of days she has taken to collect M number of stones. Please note that each query contains the different number of M.

Input:
First line contains N and Q, the number of days and number of queries. Second line contains N integers, in which ith integer denotes the number of stones she has collected on ith day.
Then next line contains Q space-separated integers, M, where ith M denotes the ith query, i.e., number of stones.

Output:
For each of the Q queries, you have to output the number of days she has taken to collect M number of stones in a new line.

Constraints:

1 <= N, Q <= 5*10^5
1 <= A[i] <= 10^5
1 <= M <= sum of all the elements in the array.

Problem Setter:

Akash Rakshit

SAMPLE INPUT
5 4
1 2 3 4 5
3 8 10 14
SAMPLE OUTPUT
2
4
4
5
Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

Notifications
View All Notifications

?