Source Code
#include <iostream>
using namespace std;

int main() {
	int com[100001];
	com[0] = 0;
	int n; cin >> n;
	int tmp, ans = 0;
	for (int i = 1; i <= n; i++) {
		cin >> tmp;
		com[i] = com[i - 1] + tmp;
		if (com[i] <= 0) {
			ans += 1-com[i];
			com[i] = 1;
		}
			
	}
	cout << abs(ans);
	//system("pause");
	return 0;
}
Copy
Zeina The Business Owner psutMoha
GNU G++17
23 ms
1.3 MB
Accepted