ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 2065. Different Sums

Seriously!!!!!Why WA??
Posted by Unsocial_A 26 Sep 2018 10:23
int main()
{
    optimize();
    int n,k;
    cin>>n>>k;
    k--;
    int z=k;
    bool b=0;
    int a[n+10];
    for(int i=0;i<n;i++)
    {
        if(k!=0)
        {
            if(b==0)
            {
                a[i]=k;
                b=1;
                z--;
            }
            else
            {
                if(z==0)
                {
                    a[i]=0;
                    k=0;
                    b=1;
                    continue;
                }
                a[i]=-k;
                k--;
                b=0;
                z--;
                if(z==0)
                    k=0;
            }
        }
        else
            a[i]=0;
    //dbg(z);
    }
    for(int i=n-1;i>=0;i--)
        cout<<a[i]<<" ";
    //return main();
}

when going to print 0 0 -3 3  or  -3 3 0 0 I am getting WA..But When I print 0 0 -1 1 I get AC..Why?what is the difference between 1st two case and last one??Can anyone explain me??