题目的意思就是找出未能及时处理的犯罪数,
#include <iostream> using namespace std; int main(){ int n; cin >> n; int a,recruit = 0, crimes = 0;; for(int i = 0 ; i < n; ++ i){ cin >> a; if(a > 0) recruit+=a; else recruit?recruit-- : crimes++; } cout<<crimes<<endl; }
题目的意思就是找出未能及时处理的犯罪数,
#include <iostream> using namespace std; int main(){ int n; cin >> n; int a,recruit = 0, crimes = 0;; for(int i = 0 ; i < n; ++ i){ cin >> a; if(a > 0) recruit+=a; else recruit?recruit-- : crimes++; } cout<<crimes<<endl; }