結果

問題 No.135 とりあえず1次元の問題
ユーザー カニ戯(ry
提出日時 2015-02-24 16:25:27
言語 Java
(openjdk 23)
結果
AC  
実行時間 666 ms / 5,000 ms
コード長 392 bytes
コンパイル時間 2,815 ms
コンパイル使用メモリ 80,148 KB
実行使用メモリ 49,572 KB
最終ジャッジ日時 2025-01-03 05:20:49
合計ジャッジ時間 9,224 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] a) {
		Scanner s = new Scanner(System.in);
		int N=s.nextInt(),i=0,d,m=Integer.MAX_VALUE;
		int[] X=new int[N];
		for(;i<N;)X[i++]=s.nextInt();
		Arrays.sort(X);
		for(i=0;i<N-1;){
			d=Math.abs(X[i]-X[++i]);
			m=(d>0&&d<m)?d:m;
		}
		System.out.println(m==Integer.MAX_VALUE?0:m);
	}
}
0