Advertisement
zunayeds

UVA 11850 solution

May 17th, 2015
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include<iostream>
  2. #include<algorithm>
  3. using namespace std;
  4.  
  5. int main() {
  6.     int n;
  7.     while (cin >> n) {
  8.         if (n == 0) {
  9.             break;
  10.         }
  11.         else {
  12.             int A[n];
  13.             for (int i = 0; i < n; i++) {
  14.                 cin >> A[i];
  15.             }
  16.             sort(A,A+n);
  17.             int c = 0;
  18.             if (A[n-1] < 1322) {
  19.                 c++;
  20.             }
  21.             else {
  22.                 for (int j = 0; j < n-1; j++) {
  23.                     if ((A[j+1]-A[j]) > 200) {
  24.                         c++;
  25.                         break;
  26.                     }
  27.                 }
  28.             }
  29.             if (c == 0) {
  30.                 cout << "POSSIBLE" << endl;
  31.             }
  32.             else {
  33.                 cout << "IMPOSSIBLE" << endl;
  34.             }
  35.         }
  36.     }
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement