Company: Amazon_28feb
Difficulty: medium
Amazon Souvenir Shop A souvenir shop keeps n items on a single shelf, numbered 1 to n from left to right. Item i has a base price cost[i] , and its price climbs every time it is bought: the first copy costs cost[i] , the second costs 2 cost[i] , the third 3 cost[i] , and in general the j -th copy of item i costs j * cost[i] . A shopper starts with m units of money. She walks the shelf from left to right and buys one item at each stop. After item n she returns to item 1 and keeps going around. She stops the moment the item she has arrived at costs more than the money she has left — she does not skip it and move on to a cheaper one. Report how many items she buys in total. Input Format Line 1: the integer m , the money the shopper starts with. Line 2: the integer n , the number of items on the shelf. The next n integers: cost[1], cost[2], ..., cost[n] , one per line. Output Format Print a single integer — the total number of items bought. Constraints 1 <= n <= 2 * 10^5 1 <= m &l