Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

getting wrong ans in THE LEAD GAME .HELP!!!!

$
0
0

cannot find what is wrong with this code of question link text . workng for most of the test cases i tried on my pc still getting wrong answer with codechef compiler . help !!

include<stdio.h>

int main()

{

int i,j,k,l,first,x=0,a,p=0,q=0,diff=0,n,b;

for(i=0;i<=n;i++)
{
    if(i==0)
    {
        scanf("%d",&n);
    }
    else
    {
        scanf("%d",&a);
        scanf("%d",&b);
        p=p+a;
        q=q+b;
        if(p>q)
        {
            if(diff<(p-q))
          {
            diff=p-q;
            x=1;
          }
        }
        else
        {
            if(diff<(q-p))
            {
                diff=q-p;
                x=2;
            }
        }
    }
}
printf("%d %d",x,diff);
return 0;

}


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>