Tangerine Tree
Time limit1sMemory limit1024 MB
Each day, N pickers take fixed amounts from a tree with M tangerines in order, and the task is to find how many remain after 10^100 days.
- Level
Medium7 of 10
- Topics
- Simulation, Math, Implementation
- Solved
- No attempts yet
Problem
Seoyun's backyard has a large tangerine tree with tangerines on it.
Gomgomi from the house next door come to pick tangerines from this tree every day. Every day, they try in order, starting with Gomgomi 1 and ending with Gomgomi . Gomgomi tries to pick tangerines. If fewer than tangerines remain on the tree, Gomgomi does nothing.
Find the number of tangerines left on the tree after days.
Input
The first line contains the number of Gomgomi and the number of tangerines , separated by a space. (, )
The second line contains the amounts that each Gomgomi tries to pick, separated by spaces. ()
All numbers in the input are integers.
Output
Print the number of tangerines left on the tree after days.