The LEAD GAME Wrong answer but worked on my devc++

Hi, I ran my code in my devc++ compiler and it ran without any problem but when i compile it on codechef, it shows wrong answer. Anyone please help!!!

Here’s my code

#include< iostream >
#include< stdio.h >
using namespace std;

int main()

{

     int N,S[10000],T[10000],i,d1=0,d2=0,W,L;

         cin>>N;


     for(i=0;i<N;i++)

        {

        	scanf("%d %d",&S[i],&T[i]);

        	if(S[i]>T[i])

        	  {

        	    if((S[i]-T[i])>d1) 

        	       d1=S[i]-T[i];
              }

        	else

        	  {

        	  	if((T[i]-S[i])>d2)

        	  	   d2=T[i]-S[i];

        	  	
        	  }
        	
        }
	if(d1>d2)

	  {

	  	 W=1;

	  	 L=d1;

	  }

	else

	  {

	  	 W=2;

	  	 L=d2;

	  }



    cout<<W<<" "<<L;

return 0;

}

If there’s a problem with the logic or if there’s anything I’ve missed out, Please tell me…

1 Like

The questions says: “The lead is the difference between the total score at the moment”
What you are doing is, taking the lead as the difference b/w the points scored in the current round. Think about cumulative sums.

2 Likes

Thanks for your help. :slight_smile:

1 Like

Try cummulative score, thats whats asked in the question.

1 Like