Programming contests

Magas szintű programozási nyelvek 1, egyéni verseny, 2016. április 10.

April 10, 2016, 10:00 AM – April 10, 2016, 3:00 PM

Jolly Jumpers

A sequence of n > 0 integers is called a jolly jumper if the absolute values of the differences between successive elements take all the values from 1 to n – 1. For instance, the sequence 1, 4, 2, 3 is a jolly jumper, because the absolute differences are 3, 2, and 1, respectively. The definition implies that any sequence of a single integer is a jolly jumper. You are to write a program to determine whether or not each of a number of sequences is a jolly jumper.

Input Specification

Each line of input starts with an integer n ≤ 3000, followed by n integers, separated by spaces, representing the sequence. The input is terminated by end-of-file (EOF).

Output Specification

For each line of input, generate a line of output saying “Jolly” or “Not jolly”.

Sample Input

  1. 4 1 4 2 3
  2. 5 1 4 2 -1 6
download as text file

Output for Sample Input

  1. Jolly
  2. Not jolly
download as text file
University of Debrecen; Faculty of Informatics; v. 09/30/2024