結果

問題 No.135 とりあえず1次元の問題
ユーザー mits58
提出日時 2016-05-05 15:19:01
言語 Java
(openjdk 23)
結果
AC  
実行時間 601 ms / 5,000 ms
コード長 592 bytes
コンパイル時間 1,806 ms
コンパイル使用メモリ 74,592 KB
実行使用メモリ 48,624 KB
最終ジャッジ日時 2024-06-11 06:49:01
合計ジャッジ時間 7,822 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main{
	public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(sc.hasNext()){
        	int n=sc.nextInt();
        	int[] x=new int[n];
        	for(int i=0;i<n;i++) x[i]=sc.nextInt();
        	Arrays.sort(x);
        	int res=Integer.MAX_VALUE/2;
        	for(int i=1;i<n;i++){
        		if(x[i]==x[i-1]) continue;
        		res=Math.min(res, x[i]-x[i-1]);
        	}
        	if(res==Integer.MAX_VALUE/2) System.out.println(0);
        	else System.out.println(res);
        }
    }
}
0