I had the dry run i am confused why is it not correct answer,
Hints what i am missing
post your submission link.
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];
if(lead<max)
lead=max;
}
// else if(player2[i]>player1[i]){
else{
max2=player2[i]-player1[i];
if(max2>lead2)
lead2=max2;
}
}
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];
if(lead<max)
lead=max;
}
// else if(player2[i]>player1[i]){
else{
max2=player2[i]-player1[i];
if(max2>lead2)
lead2=max2;
}
}
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.
still confused?
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.
but the question ask for
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
.
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
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.