Advertisement
MiinaMagdy

10038 - Jolly Jumpers

Sep 7th, 2022
642
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define ll long long
  6. #define endl '\n'
  7. #define sz(x) int(x.size())
  8. #define all(x) x.begin(), x.end()
  9.  
  10. int main() {
  11.     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  12.     int n = 0;
  13.     while (cin >> n, n) {
  14.         int prev, x;
  15.         bool jolly = 1;
  16.         bool vis[n]{};
  17.         for (int i = 0; i < n; i++) {
  18.             cin >> x;
  19.             if (i > 0) {   
  20.                 vis[abs(x - prev)] = 1;
  21.             }
  22.             prev = x;
  23.         }
  24.         for (int i = 1; i < n; i++) jolly &= vis[i];
  25.         cout << (jolly ? "Jolly" : "Not jolly") << endl;
  26.         n = 0;
  27.     }
  28. }
  29.  
Tags: UVA CP3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement