First Snow

One day Tomato woke up late in the morning and realized that she had a long list of todos. Frantical…

Click here to read the complete problem statement.


If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.

#include <iostream>

using namespace std;

int main()
{
    int n,x,d,t=0;
    cin>>n>>x>>d;
    int snwd[n];
    int snwr[n];
    for(int i=1;i<=n;i++)
    {
        cin>>snwd[i];
    }
    for(int i=1;i<=n;i++)
    {
        //cout<<snwd[i]<<"For I"<<endl;
        for(int j=1;j<=n-i;j++)
        {
            if(snwd[i]-d>=0)
            {
                snwd[i]=snwd[i]-d;
                //cout<<snwd[i]<<"For J"<<endl;
            }else
            {
                snwd[i]=0;
                //cout<<"Discarded"<<endl;
                break;
            }
        //cout<<snwd[i]<<"For I2"<<endl;
        }
        t+=snwd[i];
        //cout<<t<<"T"<<endl;
        if(t>=x)
        {
            return cout<<i , 0;
            break;
        }
    }
}

Why it is missing test case 5… More accurate, what is test case five?