結果

問題 No.135 とりあえず1次元の問題
ユーザー samplelpmassamplelpmas
提出日時 2016-11-08 03:07:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 700 ms / 5,000 ms
コード長 660 bytes
コンパイル時間 1,829 ms
コンパイル使用メモリ 71,828 KB
実行使用メモリ 66,380 KB
最終ジャッジ日時 2023-09-02 00:41:14
合計ジャッジ時間 9,571 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 700 ms
66,380 KB
testcase_01 AC 127 ms
55,952 KB
testcase_02 AC 127 ms
55,848 KB
testcase_03 AC 127 ms
55,768 KB
testcase_04 AC 136 ms
55,444 KB
testcase_05 AC 132 ms
55,376 KB
testcase_06 AC 131 ms
55,588 KB
testcase_07 AC 133 ms
55,388 KB
testcase_08 AC 131 ms
55,772 KB
testcase_09 AC 130 ms
56,028 KB
testcase_10 AC 130 ms
56,580 KB
testcase_11 AC 129 ms
56,824 KB
testcase_12 AC 146 ms
55,640 KB
testcase_13 AC 130 ms
56,188 KB
testcase_14 AC 182 ms
55,772 KB
testcase_15 AC 143 ms
55,868 KB
testcase_16 AC 182 ms
56,164 KB
testcase_17 AC 184 ms
56,092 KB
testcase_18 AC 136 ms
55,828 KB
testcase_19 AC 179 ms
56,012 KB
testcase_20 AC 170 ms
55,760 KB
testcase_21 AC 512 ms
62,936 KB
testcase_22 AC 668 ms
65,984 KB
evil01.txt AC 588 ms
62,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        Integer[] x = new Integer[n];

        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
        }

        Arrays.sort(x);

        int min = Integer.MAX_VALUE;

        for (int i = 0; i < n - 1; i++) {

            if (0 < (x[i + 1] - x[i])) {

                min = Math.min(min, x[i + 1] - x[i]);

            }

        }

        if (min == Integer.MAX_VALUE) {
            min = 0;
        }

        System.out.println(min);

    }

}
0