The lead game| My code gave correct output for the given test case but got WA

#include <stdlib.h>
int main(void) {
// your code goes here
int round,p1,p2,lead=0,winner;
scanf("%d",&round);
while(round–){
scanf("%d %d",&p1,&p2);
int score=abs(p1-p2);

    if(score>lead){
        lead=score;

        if(p1>p2){
            winner=1;
        }else{
            winner=2;
        }
    }
}
printf("%d %d",winner,lead);
return 0;

}

Pls help me to correct this.

Look at the editorial. I don’t remember, but I was having the same difficulty, but then understood that I was understanding the question wrong

Its about the cumulative scores, not the individual round scores.

You can keep a track of “cumulative diff” to correctly answer the lead for every round. Something like this

cumulative_diff = 0;
while(n--)
{
    get_input(player_1); get_input(player_2);
    round_lead = (player_1 - player_2 + cumulative_diff);
    cumulative_diff = round_lead;
    //TODO: compare round_lead to max to detect which round was the best - for player_1 or player_2
}

See my solution 58724248