First of all, I guess you need to re-read the problem statement.
The catch/trick in the problem is that at each round previous scores are added as well, so lead is calculated for the scores and it is very much clearly depicted in the problem statement.
Let me explain you with the test case given :
Round Player 1 Player 2
1 140 82
2 89 134
3 90 110
4 112 106
5 88 90
so after round 1 player 1 scores 140 and player 2 scores 82.So lead is 140-82 i.e. 58 and leader is 1.
In round 2 player 1 scores 89 and player 2 scores 134.
So according to your solution, in this round player 2 is leader and lead equals to 134-89 = 45.
But actually till now the total scores are 229 and 216 for player one and two respectively.
So player 1 is still leading but his lead has been curtailed to just 13. so we need to consider this lead not the individual round difference.
Just include this and you will get accepted. Hope you got it. PS : If you still have some questions or doubts feel free to ask and reply me @viaan on this thread itself, i’ll try my best to answer you.
have a look at the output section
i guess you are missing the space between the leader and the lead. cout<<1<<" "<< diff1 ORcout<<"1 "<< diff1
will do good.
Hope I was helpful enough and you learnt something from this problem.
@rajat_121292
No need to thank me.
It’s my pleasure.
We need to grow as Indian coding fraternity so we all are buddys here.
So If u are satisfied with the answers you can close the thread and chose the question has been answered.
Your output must consist of a single
line containing two integers W and L,
where W is 1 or 2 and indicates the
winner and L is the maximum lead
attained by the winner.
there L is maximum overall lead, but it needs to be calculated per round