Source Code
#include <iostream>
#include<math.h>
using namespace std;
int a[100000] = { 0 };
int main()
{
    int t, min = 10000;
    cin >> t;
    for (int i = 0;i < t;i++) {
        cin >> a[i];

    }
    int sum = 0;
    for (int i = 0;i < t;i++) {
        sum += a[i];
        if (sum < min) {
            min = sum;
        }

    }
    if (min >= 0) {
        cout << 0;
    }
    else {
        int out = abs(min)+1;
        cout << out;
    }
}
Copy
Zeina The Business Owner hadeelYasir
GNU G++17
23 ms
1.3 MB
Accepted