結果

問題 No.135 とりあえず1次元の問題
ユーザー Hiroaki KonoHiroaki Kono
提出日時 2017-10-31 22:43:08
言語 Java21
(openjdk 21)
結果
AC  
実行時間 706 ms / 5,000 ms
コード長 725 bytes
コンパイル時間 3,541 ms
コンパイル使用メモリ 75,872 KB
実行使用メモリ 54,700 KB
最終ジャッジ日時 2024-05-02 01:48:36
合計ジャッジ時間 10,332 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 706 ms
54,700 KB
testcase_01 AC 119 ms
41,516 KB
testcase_02 AC 125 ms
41,288 KB
testcase_03 AC 119 ms
41,584 KB
testcase_04 AC 124 ms
41,136 KB
testcase_05 AC 130 ms
41,656 KB
testcase_06 AC 137 ms
41,764 KB
testcase_07 AC 133 ms
41,548 KB
testcase_08 AC 132 ms
41,720 KB
testcase_09 AC 129 ms
41,436 KB
testcase_10 AC 129 ms
41,500 KB
testcase_11 AC 125 ms
41,280 KB
testcase_12 AC 138 ms
41,960 KB
testcase_13 AC 130 ms
41,424 KB
testcase_14 AC 177 ms
42,832 KB
testcase_15 AC 145 ms
42,060 KB
testcase_16 AC 181 ms
42,300 KB
testcase_17 AC 186 ms
42,492 KB
testcase_18 AC 135 ms
41,308 KB
testcase_19 AC 170 ms
42,324 KB
testcase_20 AC 172 ms
42,304 KB
testcase_21 AC 511 ms
48,204 KB
testcase_22 AC 670 ms
54,456 KB
evil01.txt AC 643 ms
53,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class No135 {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int count = s.nextInt();
        int[] pos = new int[count];
        for (int i = 0; i < count; i++) {
            pos[i] = s.nextInt();
        }
        pos = Arrays.stream(pos).distinct().sorted().toArray();
        if (pos.length < 2) {
            System.out.println(0);
            return;
        }
        int min = Integer.MAX_VALUE;
        for (int i = 1; i < pos.length; i++) {
            int tmp = pos[i] - pos[i - 1];
            if (min > tmp) {
                min = tmp;
            }
        }
        System.out.println(min);
    }
}
0