Computer Programming Contest Preparation

ToolBox - Source for: 100/10038/judged.java



/home/toolbox/public_html/solutions/100/10038/judged.java
    1 import java.util.Scanner;
    2 
    3 public class Main
    4 {
    5 
    6     public static void main(String[] args)
    7     {
    8         final boolean DEBUG = false;
    9 
   10         Scanner in = new Scanner(System.in);
   11 
   12         String line = in.nextLine();
   13         boolean flag = false;
   14         Scanner linereader;
   15         int totalnum;
   16         int[] numberhit;
   17         while (in.hasNext())
   18             {
   19                 numberhit = new int[3000];
   20 
   21                 if (flag) line = in.nextLine();
   22                 linereader = new Scanner(line);
   23 
   24                 totalnum = linereader.nextInt();
   25                 if (DEBUG) System.out.println("totalnum: "+totalnum);
   26 
   27                 int num1,num2,total;
   28 
   29                 num1 = linereader.nextInt();
   30                 while (linereader.hasNext())
   31                     {
   32                         num2 = linereader.nextInt();
   33                         total = num1 - num2;
   34                         if (total < 0)
   35                             total = total * -1;
   36                         if (DEBUG) System.out.printf("num1: %d, num2: %d, total: %d%n",num1,num2,total);
   37                         numberhit[total] = 1;
   38 
   39                         num1 = num2;
   40                     }
   41 
   42                 String output = "";
   43 
   44                 for (int i = 1; i < totalnum; i++)
   45                     {
   46                         if (numberhit[i] == 0)
   47                             output = "Not jolly";
   48                     }
   49                 if (output == "")
   50                     output = "Jolly";
   51 
   52                 System.out.println(output);
   53                 flag = true;
   54             }
   55     }
   56 }
   57 
   58