UVa : 11850 (Alaska)



// http://uva.onlinejudge.org/external/118/11850.html
// Runtime : 0.008
// Algo : Ad-hoc


// @BEGIN_OF_SOURCE_CODE

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>
#define INT_MAX 2147483647
#define INT_MIN -2147483647
#define pi acos(-1.0)
#define N 1000000
#define LL unsigned long long
using namespace std;


int main ()
{
    int n;

    while ( scanf ("%d", &n) && n ) {
        int a [1422 + 10];

        for ( int i = 0; i < n; i++ ) scanf ("%d", &a [i]);

        sort (a, a + n);

        bool possible = true;

        for ( int i = 1; i < n; i++ )
            if ( a [i] - a [i - 1] > 200 ) possible = false;

        if ( 2 * (1422 - a [n - 1]) > 200 ) possible = false;

        if ( possible ) printf ("POSSIBLE\n");
        else printf ("IMPOSSIBLE\n");
    }

	return 0;
}

// @END_OF_SOURCE_CODE
Advertisements

4 thoughts on “UVa : 11850 (Alaska)

  1. @NouHoney
    we need 1422 elements array. But for safety we are taking 10 more elements.
    int a [1432] is same as, int a [1422 + 10], but later one is more intuitive. Don’t you think?

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