CodeChef beginner - The Lead Game (TLG) whats wrong in my code?


#1
#include "bits/stdc++.h"
using namespace std;

int main()
{
    int t, s1, s2, lead;
    cin >> t;
    vectorp1;
    vectorp2;
    while(t--)
    {
        cin >> s1 >> s2;
        if(s1> s2)
            {
                p1.push_back(s1-s2);
            }
        else
            {
                p2.push_back(s2-s1);
            }
    }
    int max1 = *max_element(p1.begin(),p1.end());
    int max2 = *max_element(p2.begin(),p2.end());
    if( max1 > max2)
        cout << "1 " << max1;
    else
        cout << "2 " << max2;
}

#2

Problem descriptions says cumulative. You’re just adding them to the vector and taking max.


#3

It is fascinating to see this problem getting asked again and again in discussions. Kudos to the author.


#4

Kudos to him making the statement ambiguous. I got it corrected from @admin, hope this fixes this issue :frowning:


#5

Once upon a time I was also wondering about what’s wrong with my soln in the same question xD.
Solved it on my own afterwards…