d097: 10038 - Jolly Jumpers
http://zerojudge.tw/ShowProblem?problemid=d097
- while True:
- try:
- sequence=[int(i) for i in input().split()]
- n=sequence[0]
- d=list(range(1,n))
- for i in range(1,n):
- try:
- d.remove(abs(sequence[i]-sequence[i+1]))
- except:
- print(’Not jolly’)
- break
- else:
- print(’Jolly’)
- except:
- break
- while True:
- try:
- x = [int(x) for x in input().split()]
- z = x[0]
- x = x[1:]
- y = []
- for i in range(0,len(x)-1):
- y += [abs(x[i+1]-x[i])]
- y = sorted(y)
- if max(y)>z:
- print("Not jolly")
- else:
- for i in range(len(y)):
- if y[i] != i+1:
- print("Not jolly")
- break
- else:
- print("Jolly")
- except:
- break