What is the testcase in REDALERT?

Hello, everyone… I was unable to solve the Lunchtime July Problem REDALERT. This is my code.

#include <iostream>
using namespace std;

int main() {
    int t(0), water(0);
    cin >> t;

    while (t--)
    {
        int n;
        cin >> n;
        int d, h;
        cin >> d >> h;

        for (int i = 0; i < n; i++)
        {
            int x(0);
            cin >> x;

            if (x > 0) { water = water + x; }
            else if (water > d && x == 0) { water = water - d; }
            else if (water == 0 || water <= d) { water = 0; }

            if (water > h)
            {
                cout << "YES" << endl;
                water = 0, h=-1;
                break;
            }

        }

        if (water <= h)
        {
            cout << "NO" << endl;
            water = 0;
        }
    }

}

I know the h = -1 is bad in the if loop. I have seen the editorial and will try to implement flag in my code, but for the life of me I can’t figure out why is it giving WA. @soumyadeep_21 Could you please provide the second test case. I would like to try to solve the question on my own. The test case will greatly help me, Thank You.

Consider the test input:

2                                            
3 1 5
3 3 1 
3 10 1
1 1 1
1 Like

@ssjgz Thank You very much… Now I understand, that after taking 3,3 my program breaks as it has reached REDALERT. 1 still remains in the input stream, causing my program to crash as the variable n takes the value 1.

1 Like