The code chef compiler is giving wrong answer to this code…but is working fine on my PC
http://www.codechef.com/viewsolution/3611816
#include<stdio.h>
int main()
{
int r,i,min=0,max=0,a[10000],b[10000],c[10000];
scanf("%d",&r);
for(i=0;i<r;i++)
{
scanf("%d%d",&a[i],&b[i]);
c[i]=a[i]-b[i];
if(c[i]<min)
min=c[i];
if(c[i]>max)
max=c[i];
}
if(min*-1>max)
printf("2 %d",min*-1);
else
printf("1 %d",max);
return 0;
}
if both min*-1 and max are equal what should be the output
neal95
3
@swati4star For the given testcase, your code may work…but it is not correct.
here you are storing the lead values of each round in the array c[10000].
Those lead values are actually not a[i]-b[i]…it is actually
the sum of the scores of the player1 upto the "i"th round - the sum of the scores of the player2 till "i"th round…
so take care of that c[10000]…then your code may give AC for codechef compiler also
If this helps…hope you can upvote and accept the answer…
All the Best
2 Likes
It is given in the question that…
" You may assume that the scores will be such that there will
always be a single winner. That is, there are no ties."