結果

問題 No.135 とりあえず1次元の問題
ユーザー tentententen
提出日時 2020-11-10 16:19:44
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 591 bytes
コンパイル時間 2,167 ms
コンパイル使用メモリ 72,664 KB
実行使用メモリ 67,216 KB
最終ジャッジ日時 2023-09-29 23:39:11
合計ジャッジ時間 8,453 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 576 ms
67,216 KB
testcase_01 AC 103 ms
56,056 KB
testcase_02 AC 105 ms
55,716 KB
testcase_03 WA -
testcase_04 AC 114 ms
55,732 KB
testcase_05 AC 114 ms
56,036 KB
testcase_06 AC 116 ms
56,092 KB
testcase_07 AC 120 ms
56,108 KB
testcase_08 AC 114 ms
56,084 KB
testcase_09 AC 115 ms
56,224 KB
testcase_10 AC 114 ms
55,988 KB
testcase_11 AC 118 ms
56,432 KB
testcase_12 AC 131 ms
56,140 KB
testcase_13 AC 113 ms
55,796 KB
testcase_14 AC 169 ms
56,144 KB
testcase_15 AC 129 ms
55,744 KB
testcase_16 AC 164 ms
56,584 KB
testcase_17 AC 168 ms
57,116 KB
testcase_18 AC 117 ms
56,248 KB
testcase_19 AC 162 ms
56,700 KB
testcase_20 AC 159 ms
56,416 KB
testcase_21 AC 474 ms
58,692 KB
testcase_22 AC 597 ms
67,200 KB
evil01.txt AC 538 ms
67,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        TreeSet<Integer> set = new TreeSet<>();
        for (int i = 0; i < n; i++) {
            set.add(sc.nextInt());
        }
        if (set.size() == 0) {
            System.out.println(0);
        }
        int prev = Integer.MIN_VALUE / 10;
        int min = Integer.MAX_VALUE;
        for (int x : set) {
            min = Math.min(min, x - prev);
            prev = x;
        }
        System.out.println(min);
    }
}
0