Friday, April 24, 2015

UVa 11850 - Alaska

#include <algorithm>
#include <stdio.h>
using namespace std;

#define END_MILE 1422
#define MILES_AFTER_RECHARGE 200

int main() {
	int n;
	int stations[END_MILE + 2];
	scanf("%d", &n);
	while (n) {
		for (int i = 0; i < n; i++)
			scanf("%d", &stations[i]);
		sort(stations, stations + n);
		bool possible = true;
		for (int i = 1; i < n; i++) {
			if (stations[i] - stations[i - 1] > MILES_AFTER_RECHARGE) {
				possible = false;
				break;
			}
		}
		if (possible && ((END_MILE - stations[n - 1]) * 2 <= MILES_AFTER_RECHARGE))
			printf("POSSIBLE\n");
		else
			printf("IMPOSSIBLE\n");
		scanf("%d", &n);
	}
	return 0;
}

No comments:

Post a Comment