The Lead Game, what's wrong with my code?


int main()
int r=0, p1=0,i,j,p2=0;
int temp=0,lead=0;


for(i=0; i<r; i++){
	scanf("%d %d",&p1,&p2);
	//if((p1<0 || p1>1000)||(p2<0 || p2> 1000)){break;}
		if(temp<(p1-p2)){ temp = p1-p2;lead=1;}
	else if(p2>p1){
		if(temp<(p2-p1)){ temp = p2-p1;lead=2;}
printf("%d %d\n",lead,temp);

return 0;


Read the Q carefully, especially the second table. The lead is the CUMULATIVE LEAD or lead on CUMULATIVE SCORE, not individual score.

Eg- If player A has lead of 80 till now, next round B gets lead of 100, then overall lead of B is 20, not 100.

this is there in discuss for how many times , i really donot know. give a search , every next day i find this question asked by someone .

Yup. Nobody gives forums a search :frowning: