結果

問題 No.135 とりあえず1次元の問題
ユーザー spacia
提出日時 2015-12-23 14:11:56
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 653 bytes
コンパイル時間 2,854 ms
コンパイル使用メモリ 77,224 KB
実行使用メモリ 52,212 KB
最終ジャッジ日時 2025-01-03 10:59:24
合計ジャッジ時間 6,104 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

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