Source Code
#include <iostream>
using namespace std;

int main() {

	int days;
	cin >> days;
	int* arr = new int[days];
	for (int i = 0;i < days;i++) {
		cin >> arr[i];
	}

	int n = 0;
	int lend = 0;
	for (int i = 0;i < days;i++)
	{
		n += arr[i];
		if (n < 1)
		{
			lend += 1 - n;
			n += lend;
		}
	}

	cout << lend << endl;

	return 0;
}
Copy
Zeina The Business Owner Qusay
GNU G++17
2 ms
620 KB
Wrong Answer