結果

問題 No.135 とりあえず1次元の問題
ユーザー fal_rnd
提出日時 2016-11-29 00:40:44
言語 Java
(openjdk 23)
結果
AC  
実行時間 606 ms / 5,000 ms
コード長 462 bytes
コンパイル時間 2,575 ms
コンパイル使用メモリ 76,856 KB
実行使用メモリ 55,748 KB
最終ジャッジ日時 2024-06-11 07:08:57
合計ジャッジ時間 8,362 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
class B{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args) {
		TreeSet<Integer> b = new TreeSet<Integer>();
		for(int i=Integer.parseInt(s.next());i>0;--i) {
			b.add(Integer.parseInt(s.next()));
		}
		Integer[] in = b.toArray(new Integer[0]);

		int r=Integer.MAX_VALUE;
		for(int i=0;i<in.length-1;++i) {
			r=Math.min(r, Math.abs(in[i]-in[i+1]));
		}
		System.out.println((r==Integer.MAX_VALUE)?0:r);
	}
}
0