Chef and Chocolates
All submissions for this problem are available.
On the occasion of Republic day, Chef wants to give away chocolates to the students. N students are eagerly waiting for the Chef and they have formed a queue.
Chef has u variety of chocolates. Looking at the strength of the students he is sure that he cannot provide chocolates of all the variety to all the students. He decided that he will start from ith student and end at jth student (0 ≤ i,j < N) and will give them K number of chocolates to each student. In the same manner chef distributed all the varieties of chocolates.
Now Lemon Kumar, who is a very friendly student (as his other name is Yaar Kumar), has M number of friends. He knows the positions of each of his friend in the queue. Now he wants to query for each friend, how many chocolates his friend standing on pth position got.
First line consists of T, the number of test cases.
Each test case consists of two number, N u, the number of students in the queue and the number of varieties of chocolates Chef has.
Then follow u lines, giving description of distribution of each variety of chocolate, in the format "i j k".
Next line contains M, the number of friends of Lemon Kumar.
Next M lines contain a position p of Lemon's friend standing in the line.
For each test case, print the result of the query for M friends, each on a separate line..
- 1 ≤ T ≤ 30
- 1 ≤ N ≤ 10000
- 1 ≤ u ≤ 105
- 0 ≤ i,j<N
- 0 ≤ k<10000
- 1 ≤ M<10000
- 0 ≤ p<N
Input: 1 6 4 3 5 2 2 4 3 1 5 1 0 2 4 4 4 3 2 0 Output: 6 6 8 4
|Time Limit:||0.5 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions