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.
-----------------------------------------------------
你所在城市的警察局剛剛開(kāi)始其旅程。 最初,他們沒(méi)有任何人力。 于是,他們開(kāi)始分組招募新人。
與此同時(shí),城市內(nèi)犯罪不斷發(fā)生。 一名警察在其一生中只能調(diào)查一項(xiàng)犯罪行為。
如果犯罪發(fā)生期間沒(méi)有警察空閑(不忙于犯罪),犯罪就會(huì)得不到處理。
根據(jù)犯罪發(fā)生和新兵招聘的時(shí)間順序,找出未得到處理的犯罪數(shù)量。
輸入
輸入的第一行將包含一個(gè)整數(shù) n (1?≤?n?≤?105),即事件數(shù)。 下一行將包含 n 個(gè)空格分隔的整數(shù)。
如果整數(shù)為-1,則表示發(fā)生了犯罪。 否則,該整數(shù)將為正數(shù),即當(dāng)時(shí)一起招募的軍官人數(shù)。 一次招募的軍官不超過(guò)10人。
輸出
打印一個(gè)整數(shù),即未得到處理的犯罪數(shù)量。
----------------------------------------------
直接模擬即可;