|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|5 초||512 MB||18||10||7||100.000%|
The sale bin of Big Box Bargains contains n products in a row. The ith item has price ai per unit. There is no limit to the quantity of any item.
There are q customers who will enter the store to buy items. The ith customer has vi dollars, starts at item li and walks to the right to item ri (inclusive), one item at a time.
Each time they encounter an item, they will buy as many units of the item as they can afford.
You are now wondering, for each customer, how much money they will have left after buying items.
The first line of input contains two space-separated integers n and q (1 ≤ n, q ≤ 200,000).
The next line of input contains n space-separated integers ai (1 ≤ ai ≤ 1018).
Each of the next q lines contains three space-separated integers vi (1 ≤ vi ≤ 1018), li , and ri (1 ≤ li ≤ ri ≤ n).
For each of the q customers, print, on a single line, a single integer indicating the remaining amount of money after shopping.
5 3 5 3 2 4 6 8 5 5 107 1 4 7 3 5
2 0 1