-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path10038.cpp
More file actions
75 lines (73 loc) · 936 Bytes
/
10038.cpp
File metadata and controls
75 lines (73 loc) · 936 Bytes
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* USER: 93043 (mkbs_cse09) */
/* PROBLEM: 979 (10038 - Jolly Jumpers) */
/* SUBMISSION: 09479628 */
/* SUBMISSION TIME: 2011-11-17 07:53:26 */
/* LANGUAGE: 1 */
#include<stdio.h>
long a[3005],d[3005];
int main()
{
long k,n,i,flag,e,d1;
while(scanf("%ld",&n)!=EOF)
{
i=0;
flag=0;
for(k=1;k<=n;k++)
{
scanf("%ld",&a[k]);
}
for(k=1;k<n;k++)
{
if(a[k]>a[k+1])
{
d[k]=a[k]-a[k+1];
}
else
{
d[k]=a[k+1]-a[k];
}
if(d[k]<0)
{
d[k]=(-1)*d[k];
}
if(d[k]>=n)
{
flag=1;
break;
}
}
if(flag==0)
{
for(i=n-1;i>=1;i--)
{
for(k=1;k<=i-1;k++)
{
if(d[k]>d[k+1])
{
e=d[k];
d[k]=d[k+1];
d[k+1]=e;
}
}
}
for(i=1;i<n-1;i++)
{
d1=d[i+1]-d[i];
if(d1>1||d1==0)
{
flag=1;
break;
}
}
}
if(flag==0)
{
printf("Jolly\n");
}
else
{
printf("Not jolly\n");
}
}
return 0;
}