結果

問題 No.135 とりあえず1次元の問題
コンテスト
ユーザー spacia
提出日時 2015-12-23 14:11:56
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
WA  
実行時間 -
コード長 653 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,759 ms
コンパイル使用メモリ 82,648 KB
実行使用メモリ 51,524 KB
最終ジャッジ日時 2026-06-06 14:59:36
合計ジャッジ時間 4,389 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

class Main135 {
	
	public static void out (Object o) {
		System.out.println(o);
	}
	
	public static void main (String[] args) throws IOException {
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		String[] line = br.readLine().split(" ");
		int[] nums = new int[n];
		for (int i = 0; i < n; i++) nums[i] = Integer.parseInt(line[i]);
		
		int ans = Integer.MAX_VALUE;
		Arrays.sort(nums);
		for (int i = 1; i < n; i++) {
			int sub = nums[i] - nums[i - 1];
			if (sub != 0 && sub < ans) ans = sub;
		}
		
		out(n == 1 ? 0 : ans);
		
	}
}
0