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

×

TLG: Getting wa

My code is

int main()
{

    int n,s1,s2,p,i,temp_p;    
    int lead,max_lead=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d%d",&s1,&s2);
        if(s1>s2)
        {
            lead=s1-s2;
            temp_p=1;
        }
        else
        {
            lead=s2-s1;
            temp_p=2;
        }

        if(lead>max_lead)
        {
            max_lead=lead;
            p=temp_p;
        }

    }
    printf("%d %d",p,max_lead);
    return 0;
}

It works fine in my compiler for the sample input given in problem but shows "Wrong Answer" here.

asked 25 Mar '12, 21:48

cool_techie's gravatar image

2★cool_techie
28971218
accept rate: 22%

edited 10 Jul '12, 12:32

admin's gravatar image

0★admin ♦♦
19.8k350498541

you are getting WA since your submission is not passing the test cases. sample test cases in problem statement are only for explanatory purpose and they are not the test cases that a judge runs to validate your submission.

(29 Mar '12, 15:22) tojochacko ♦2★

can you point out as to where the code may be wrong....

(30 Mar '12, 00:32) cool_techie2★

In his version, 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.

Actually, the problem statement is not quite clear about the way the lead has to be calculated. But in fact, you have to consider the cumulated lead over each turn, not the lead for each turn. The sample test case given is kinda misleading because of that. You just have to change your formula to compute the lead value. Good luck !

PS: the problem code is not INTEST as you wrote it in the title, it's TLG.

link

answered 27 Mar '12, 01:34

cyberax's gravatar image

3★cyberax ♦
3.4k21955
accept rate: 20%

edited 27 Mar '12, 01:35

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:

×1,070
×62

question asked: 25 Mar '12, 21:48

question was seen: 1,535 times

last updated: 15 Feb '18, 22:32