結果

問題 No.135 とりあえず1次元の問題
ユーザー atkrymatkrym
提出日時 2016-10-24 12:22:02
言語 Java21
(openjdk 21)
結果
AC  
実行時間 732 ms / 5,000 ms
コード長 663 bytes
コンパイル時間 2,156 ms
コンパイル使用メモリ 74,348 KB
実行使用メモリ 67,372 KB
最終ジャッジ日時 2023-09-02 00:37:25
合計ジャッジ時間 9,806 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 694 ms
67,060 KB
testcase_01 AC 125 ms
55,760 KB
testcase_02 AC 126 ms
55,752 KB
testcase_03 AC 128 ms
55,752 KB
testcase_04 AC 140 ms
56,080 KB
testcase_05 AC 138 ms
56,172 KB
testcase_06 AC 139 ms
55,980 KB
testcase_07 AC 137 ms
55,604 KB
testcase_08 AC 139 ms
55,844 KB
testcase_09 AC 138 ms
55,680 KB
testcase_10 AC 137 ms
55,860 KB
testcase_11 AC 141 ms
55,988 KB
testcase_12 AC 159 ms
55,776 KB
testcase_13 AC 139 ms
56,392 KB
testcase_14 AC 195 ms
56,492 KB
testcase_15 AC 158 ms
55,700 KB
testcase_16 AC 194 ms
56,084 KB
testcase_17 AC 193 ms
58,276 KB
testcase_18 AC 142 ms
55,828 KB
testcase_19 AC 192 ms
56,028 KB
testcase_20 AC 189 ms
56,032 KB
testcase_21 AC 596 ms
62,632 KB
testcase_22 AC 732 ms
67,372 KB
evil01.txt AC 653 ms
63,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.math.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        List<Integer> list = new ArrayList<>();
        int n = sc.nextInt();
        for (int i = 0;i < n;i++) {
            list.add(sc.nextInt());
        }
        Collections.sort(list);
        int ret = Integer.MAX_VALUE;
        int abs;
        for (int i = 1;i < n;i++) {
            abs = Math.abs(list.get(i)-list.get(i-1));
            if (abs != 0) ret = Math.min(ret, abs);
        }
        ret = ret==Integer.MAX_VALUE?0:ret;
        System.out.println(ret);
    }
}
0