# WA, which logic missing?

https://www.codechef.com/submit/TLG

I had the dry run i am confused why is it not correct answer,
Hints what i am missing

1 Like

I think first you need to sum prev and current round score and then need to count then lead.
update

``````		for(int i=0;i<n;i++){
if(player1[i]>player2[i]){
max=player1[i]-player2[i];
}

// else if(player2[i]>player1[i]){
else{
max2=player2[i]-player1[i];
}

}
``````

code with

``````for(int i=0;i<n;i++){
if(i!=0){
player1[i] += player1[i-1];
player2[i] += player2[i-1];
}
if(player1[i]>player2[i]){
max=player1[i]-player2[i];
}

// else if(player2[i]>player1[i]){
else{
max2=player2[i]-player1[i];
}
}``````
1 Like

Once all the rounds are over the player who had the maximum lead at the end of any round in the game is declared the winner.

In question its said to calculate lead for round in which the players have the maximum lead ?

`The Manager of Siruseri Sports Club decided to add his own twist to the game by changing the rules for determining the winner. In his version, at the end of each round, the cumulative score for each player is calculated, and the leader and her current lead are found. Once all the rounds are over the player who had the maximum lead at the end of any round in the game is declared the winner.`

1 Like

still confused?

1 Like

my question is, for each round any of the players is in lead, i need to find the maximum lead between the player 1/2, so why is addition required.
for each round i check the the leader and its lead, this what the is being asked.
And print the player with maximum lead.

this .

for input

``````4
1 2
1 2
1 2
3 1
``````

your code gives output `1 2` but correct output will be `2 3`.

1 Like

Once all the rounds are over the player who had the maximum lead at the end of any round in the game is declared the winner. only thought of this.

after all dry run test i understood, and submitted. THANK YOU.
issue solved.

atleast give a like

3 Likes

how can i connect with you, you are 4 star

No Iām not a 4 star, I was lucky that I solved 3 question in Lunchtime and got into div 1. It will be better if you post your doubt here so that everyone can help you.

2 Likes