I tried the TLG question using vectors , showing WA

I tried the TLG question using arrays and vectors…it worked fine in my compiler…but is showing wrong answer here on Codechef. Please help me.Link of my solution is added below:
My solution

Probably you didn’t understand the problem statement completely. The input is the scores of players in each round, and the winner is calculated by the "cumulative scores " of the rounds. You’re taking the difference of scores of each round. See the example given in the problem statement for further clarifications…

oh…thanks …i modified my code…but I am still getting wrong answer :cry:
Here’s my modified code:
https://www.codechef.com/viewsolution/34929467

You weren’t finding the maximum properly. I’ve altered your code a bit.
This gives you an AC :

solution

Thanks a lot…I thought my whole logic was wrong ,that which I had done with vectors…ok…so that was correct…I get it now :smile:

What is the *max_element() function you used?.. :sweat_smile:
and its actually under which header ?

Just use #include <bits/stdc++.h>. You don’t need to include anything else if you use this.
*max_element() returns the element in a vector with the largest value.