# problem tlg help

http://ideone.com/4BViVd what is wrong with this solution of tlg

In the problem statement you are required to calculate the lead of the each player and find the maximum lead of them â€¦ LEAD means that the while the game is in progress you keep on getting your score added to the previous scores and if you still win you are in LEAD

You are just taking each of the score of the player and then checking the maximum from that .Hope your understood that, if not donâ€™t hesitate to prompt me.

HAPPY CODING

sorry nickzuck_007 but i did not understand what you are trying to say i guess i interpreted the question wrongly

sorry nick but i read question again but its not asking to calculate the the sum of all score and then compare

@rahulsup

Bro you missed & in

```
scanf("%d%d",&p1,p2);
```

and on fixing that bug your code gives output
```2 2
```

for input:

```5
140 82
89 134
90 110
112 106
88 90
```

where as actual output should be

```Output:
1 58
```

Considering one more test case

```Input:
15
140 82
89 134
90 110
112 106
88 90
129 112
2 69
0 67
220 34
13 579
246 456
121 20
4 950
146 674
941 897

Expected Output:
2 2083

44 1
```

Try to fix other bugsâ€¦

and if you need help, discussion forum is always there for youâ€¦

Happy Debuggingâ€¦

1 Like

thanks rishabh

most welcomeâ€¦

1 Like

#include
#include
using namespace std;
int main()
{
int long t,i,p1,p2,c,position=0,max=0;
int a[10002];
scanf("%d\n",&t);
for(i=0;i<t;i++)
{
scanf("%d%d",&p1,&p2);
if(p1>p2)
{
c=p1-p2;
a[2i]=c;
a[2
i+1]=1;
}
if(p2>p1)
{
c=p2-p1;
a[2i]=c;
a[2
i+1]=2;
}

``````}
max=a[0];
for(i=0;i<2*t;i++)
{
if(a[2*i]>a[0])
{
max=a[2*i];
position=2*i+1;
}
}
printf("%d%d",max,a[position]);
``````

}

can you tell me my mistake

Let us suppose we are allowed to have the same scores (i.e Draw) â€¦And suppose the scores are in the order as :

1 2

1 1

4 2

``````Total1    Total2    Lead    Winner
1         2         1       2
2         3         1       2
6         5         1       1
``````

The reason for this is the described in the table below:
And apart from the bugs reported by @rishabhprsd7 â€¦There is one more bug in the line when you print your answer you are missing the space between the two outputs

Do prompt if you still have any doubts

HAPPY CODING

Iâ€™m sorry for asking this but is the question about comparison between the total score of the players or maximum lead in a round? Because as I read the question, in paragraph 2 it states that â€śthe player with the higher
total score is declared the winnerâ€ť. Now Iâ€™m confused.

Thanks for the help.

@savitrasapre is your solution showing the correct ans

No. Though when I run it through the sample provided it is giving the desired result. I donâ€™t know why is it saying â€śWrong Answerâ€ť.

@rahulsup && @savitasapre â€¦If you watch cricket you may notice that in a test match the team with the highest number of total score is declared as the winner after the 2 innings â€¦ A team who is not the winner may definitely have the lead in the first game.An almost same question is here but with the condition that the winner is the one who have scored the maximum lead corresponding to a particular innings (round) in a game â€¦@savitasapre you may check my above answers for better understanding

I am not saying you to calculate the sum of all the scores neither â€¦I am asking to calculate the sum till the point the game has already been proceeded and then check for the LEAD ,since when the game is in continuation past records are not lost â€¦once a game has finished all the rounds you must loose all the previous values of the playersâ€¦You must try by watching a test match or getting some details by your friend about test matches in cricket â€¦If you still have doubts , ask them