Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

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

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

int main()
{
    int t, s1, s2, lead;
    cin >> t;
    vector<int>p1;
    vector<int>p2;
    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;
}

Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>