結果

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

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int [] X = new int [N];
        for(int i=0; i<N; i++){
            X[i] = sc.nextInt();
        }
        Arrays.sort(X);
        int min = Integer.MAX_VALUE;
        for(int i=1; i<N; i++){
            int t = X[i]-X[i-1];
            if(t!=0){
                min=Math.min(min,t);
            }
        }
        if(min==Integer.MAX_VALUE){
            System.out.println(0);
        }else{
            System.out.println(min);
        }
    }
}
0