Friday, February 18, 2011

11805 - Bafana Bafana


#include<iostream>
#include<algorithm>
using namespace std;

int station[2000];
bool possible(int);

int main()
{
    register int n,i;
    //freopen("in.txt","r",stdin);

    while(scanf("%d",&n)&&n)
    {
        for(i=0;i<n;i++)
            scanf("%d",&station[i]);
        sort(station,station+n);

        if(possible(n-1))
            printf("POSSIBLE\n");
        else
            printf("IMPOSSIBLE\n");
    }
    return 0;
}

bool possible(int n)
{
    int i;
    if(1422-station[n]>100)return false;
    for(i=0;i<n;i++)
        if(station[i+1]-station[i]>200)
            return false;
    return true;
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.