File size: 587 Bytes
c4b0eef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
#include <set>

using namespace std;

int main(){

  int n, actual, next;
  set<int> myset;
  while(cin >> n){
    myset.clear();
    cin >> actual;
    for(int i=1; i < n; i++){
      cin >> next;
      myset.insert(max(actual, next)-min(actual, next));
      // cout << max(actual, next)-min(actual, next) << endl;
      actual = next;
    }
    bool res = true;
    for(int i=1; i<n; i++){
      if(myset.find(i) == myset.end()){
         res = false;
         break;
      }
    }
    if(res) cout << "Jolly\n";
    else cout << "Not jolly\n";
  }

  return 0;
}