Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

What's wrong with my code..??

Posted by Steinersp at 2006-12-11 16:04:14 on Problem 2575
I got Runtime Error... and I don't know why...!!
I run the program on my PC and It runs perfect... Please help me...


import java.io.*;
import java.util.*;

class Main {
	
	static int jolly[];
	static int jumper[];
	
	public static boolean judge() {
		
		for (int i = 0; i < jumper.length; i ++)
			if (jumper[i] != (i + 1))
				return false;
		
		return true;
	}
	
	public static void main(String args[]) throws IOException {
		
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		String linea;
		while ((linea = in.readLine()) != null) {
			
			int index = linea.indexOf(' ');
			int n = new Integer(linea.substring(0, index));
			
			String token[] = linea.substring(index + 1, linea.length()).split("\\s");
			jolly = new int[n];
			for (int i = 0; i < n; i ++)
				jolly[i] = new Integer(token[i]);
			
			jumper = new int[n - 1];
			for (int i = 0; i < n - 1; i ++)
				jumper[i] = Math.abs(jolly[i] - jolly[i + 1]);
			
			Arrays.sort(jumper);
			if (judge())
				System.out.println("Jolly");
			else
				System.out.println("Not jolly");
		}
	}
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator