結果

問題 No.135 とりあえず1次元の問題
ユーザー dazydazy
提出日時 2016-09-14 06:14:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 744 ms / 5,000 ms
コード長 576 bytes
コンパイル時間 3,525 ms
コンパイル使用メモリ 73,440 KB
実行使用メモリ 67,372 KB
最終ジャッジ日時 2023-09-02 00:33:08
合計ジャッジ時間 11,192 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 731 ms
67,372 KB
testcase_01 AC 125 ms
55,940 KB
testcase_02 AC 124 ms
56,172 KB
testcase_03 AC 125 ms
54,044 KB
testcase_04 AC 135 ms
57,548 KB
testcase_05 AC 138 ms
55,856 KB
testcase_06 AC 140 ms
55,884 KB
testcase_07 AC 138 ms
55,856 KB
testcase_08 AC 139 ms
55,648 KB
testcase_09 AC 138 ms
55,828 KB
testcase_10 AC 140 ms
55,880 KB
testcase_11 AC 140 ms
55,804 KB
testcase_12 AC 156 ms
55,820 KB
testcase_13 AC 139 ms
55,696 KB
testcase_14 AC 195 ms
55,408 KB
testcase_15 AC 157 ms
55,544 KB
testcase_16 AC 198 ms
55,812 KB
testcase_17 AC 192 ms
56,384 KB
testcase_18 AC 146 ms
55,816 KB
testcase_19 AC 196 ms
55,800 KB
testcase_20 AC 179 ms
56,060 KB
testcase_21 AC 603 ms
63,164 KB
testcase_22 AC 744 ms
66,128 KB
evil01.txt AC 687 ms
63,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Run {
    public static void main (String arg[]) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        ArrayList<Integer> X = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            X.add(scan.nextInt());
        }
        Collections.sort(X);
        int min = X.get(1) - X.get(0);
        int tmp;
        for (int i = 1; i < N - 1; i++) {
            tmp = X.get(i+1) - X.get(i);
            if (tmp!=0 && (min==0 || tmp < min)) min = tmp;
        }
        System.out.println(min);
    }
}
0