You are not logged in. Please login at www.codechef.com to post your questions!

×

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

#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;
}

asked 05 Aug '18, 20:15

tommotaku's gravatar image

2★tommotaku
-3
accept rate: 0%

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

(06 Aug '18, 01:06) utkalsinha6★

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

(06 Aug '18, 01:11) vijju123 ♦♦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...

(06 Aug '18, 08:33) l_returns5★

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

link

answered 06 Aug '18, 00:31

tieros's gravatar image

4★tieros
734
accept rate: 12%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×151
×70
×56
×42
×11

question asked: 05 Aug '18, 20:15

question was seen: 113 times

last updated: 06 Aug '18, 11:36