IARCS (The Lead Game)



/* Question:
http://www.iarcs.org.in/inoi/contests/sep2004/Basic-2.php
Author : Tausiq */

#include <stdio.h>

int main ()
{
    int N;
    scanf ("%d", &N);

    int player_1 = 0;
    int player_2 = 0;
    int lead;
    int max_lead = 0;
    int lead_player;
    int winner;

    while ( N-- ) {

        int S, T;
        scanf ("%d %d", &S, &T);

        player_1 += S;
        player_2 += T;

        lead = player_1 - player_2;
        lead_player = 1;

        if ( lead < 0 ) {
            lead *= -1;
            lead_player = 2;
        }

        if ( lead > max_lead ) {
            max_lead = lead;
            winner = lead_player;
        }
    }

    printf ("%d %d\n", winner, max_lead);
    return 0;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s