At the end of each round the leader and her current lead are calculated. 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.

EXPLANATION:

Create two arrays(Player1-Stores the scores of player 1 in all the rounds)[a1,a2,a3…an] and (Player2-Stores the scores of player 2 in all the rounds)[b1,b2,b3…bn].

Create a third array “Lead” such that the i’th element of Lead is ((a1+a2…+ai) - (b1+b2…bi)).
Create a fourth array “modulus lead” such that the i’th element of this array is the modulus of the i’th element of “Lead”.

Find the maximum element of “modulus lead”.This is the maximum lead attained by the winner.If the element in the corresponding position of “lead” is positive then player 1 is the winner,otherwise player 2 is.

int main()
{
int totalRounds, lead, maxLead1 = 0, maxLead2 = 0;
cin >> totalRounds;

int **stats = new int*[totalRounds];
for (int i = 0; i < totalRounds; i++)
stats[i] = new int[totalRounds];
for (int i = 0; i < totalRounds; i++)
cin >> stats[0][i] >> stats[1][i];
for (int i = 0; i < totalRounds; i++)
{
if (stats[0][i] > stats[1][i])
{
lead = stats[0][i] - stats[1][i];
if (lead > maxLead1)
maxLead1 = lead;
}
else
{
lead = stats[1][i] - stats[0][i];
if (lead > maxLead2)
maxLead2 = lead;
}
}
if (maxLead1 >= maxLead2)
cout << "1 " << maxLead1;
else
cout << "2 " << maxLead2;
for (int i = 0; i < totalRounds; i++)
delete[] stats[i];
delete[] stats;
return 0;

}

I use a 2d array to store the data of the score of the two players as below:
[0][i] (1st Player) [1][i] (2nd Player)
[0][0] [1][0] <-- 1st Round
[0][1] [1][1] <-- 2nd Round
… … <-- … Round
[0][i - 1] [1][i - 1] <-- ith Round

My Code is working absolutely fine with all the test cases and other custom inputs also but the moment i hit submit,it shows wrong answer.Can anyone help figure out the problem. Heres myn code. CodeChef: Practical coding for everyone

I have written program in python and its showing NZEC.

The Lead Game:

i = 0

score_dif= 0
p1_score,p2_score = 0,0

while True:
rounds = int(raw_input())
if rounds <= 10000:break
else : continue
while i < rounds :

p1_score,p2_score = map(int, raw_input().split())
if (1 <= p1_score <= 1000) and (1 <= p2_score <= 1000) and (p1_score != p2_score):
lead = p1_score - p2_score
if p1_score > p2_score and lead > score_dif:
score_dif = lead
elif p1_score < p2_score and abs(lead) > score_dif:
score_dif = lead
i += 1
else : continue

My code is giving the correct answer for all the testcases ive manually inputed and is still not getting accepted, please check it out and if there’s a mistake, cam somebody point it out ? !

I did it without use of arrays in a much small way.
The problem statement is pretty much vague. We need to sum up all the points up to the current round, find the lead at the end of the round, compute the lead and display the maximum lead out of the calculated leads and the the corresponding winner.