結果

問題 No.135 とりあえず1次元の問題
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-13 22:55:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 575 ms / 5,000 ms
コード長 617 bytes
コンパイル時間 3,394 ms
コンパイル使用メモリ 71,692 KB
実行使用メモリ 61,236 KB
最終ジャッジ日時 2023-09-02 00:44:10
合計ジャッジ時間 9,147 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 575 ms
61,236 KB
testcase_01 AC 123 ms
55,908 KB
testcase_02 AC 120 ms
55,832 KB
testcase_03 AC 123 ms
56,032 KB
testcase_04 AC 133 ms
55,972 KB
testcase_05 AC 132 ms
55,760 KB
testcase_06 AC 132 ms
56,308 KB
testcase_07 AC 132 ms
56,168 KB
testcase_08 AC 132 ms
55,628 KB
testcase_09 AC 133 ms
56,520 KB
testcase_10 AC 130 ms
55,684 KB
testcase_11 AC 132 ms
55,972 KB
testcase_12 AC 149 ms
56,180 KB
testcase_13 AC 130 ms
56,180 KB
testcase_14 AC 180 ms
55,488 KB
testcase_15 AC 146 ms
55,468 KB
testcase_16 AC 180 ms
56,232 KB
testcase_17 AC 180 ms
55,916 KB
testcase_18 AC 137 ms
55,792 KB
testcase_19 AC 179 ms
56,172 KB
testcase_20 AC 174 ms
56,108 KB
testcase_21 AC 528 ms
60,392 KB
testcase_22 AC 557 ms
60,488 KB
evil01.txt AC 566 ms
60,980 KB
権限があれば一括ダウンロードができます

ソースコード

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