結果

問題 No.135 とりあえず1次元の問題
ユーザー kohaku_kohaku
提出日時 2016-11-12 07:59:16
言語 Java
(openjdk 23)
結果
AC  
実行時間 753 ms / 5,000 ms
コード長 629 bytes
コンパイル時間 2,219 ms
コンパイル使用メモリ 74,232 KB
実行使用メモリ 48,568 KB
最終ジャッジ日時 2024-06-11 07:07:00
合計ジャッジ時間 9,889 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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 temp = X[i]-X[i-1];
            if(temp!=0 && min>=temp){
                min = temp;
            }
        }
        if( min!=Integer.MAX_VALUE ){
            System.out.println(min);
        }else{
            System.out.println(0);
        }
    }
}
0