CF 427A - Police Recruits
The police department of your city has just started its journey. Initially, they don’t have any manpower. So, they started hiring new recruits in groups.
Meanwhile, crimes keeps occurring within the city. One member of the police force can investigate only one crime during his/her lifetime.
If there is no police officer free (isn't busy with crime) during the occurrence of a crime, it will go untreated.
Given the chronological order of crime occurrences and recruit hirings, find the number of crimes which will go untreated.
Input
The first line of input will contain an integer n (1 ≤ n ≤ 105), the number of events. The next line will contain n space-separated integers.
If the integer is -1 then it means a crime has occurred. Otherwise, the integer will be positive, the number of officers recruited together at that time. No more than 10 officers will be recruited at a time.
Output
Print a single integer, the number of crimes which will go untreated.
-----------------------------------------------------
你所在城市的警察局刚刚开始其旅程。 最初,他们没有任何人力。 于是,他们开始分组招募新人。
与此同时,城市内犯罪不断发生。 一名警察在其一生中只能调查一项犯罪行为。
如果犯罪发生期间没有警察空闲(不忙于犯罪),犯罪就会得不到处理。
根据犯罪发生和新兵招聘的时间顺序,找出未得到处理的犯罪数量。
输入
输入的第一行将包含一个整数 n (1 ≤ n ≤ 105),即事件数。 下一行将包含 n 个空格分隔的整数。
如果整数为-1,则表示发生了犯罪。 否则,该整数将为正数,即当时一起招募的军官人数。 一次招募的军官不超过10人。
输出
打印一个整数,即未得到处理的犯罪数量。
----------------------------------------------
直接模拟即可;