TLG: Getting wa

tlg
wa

#1

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.


#2

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.


#3

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.


#4

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