結果

問題 No.135 とりあえず1次元の問題
ユーザー Hiroaki KonoHiroaki Kono
提出日時 2017-10-31 22:43:08
言語 Java21
(openjdk 21)
結果
AC  
実行時間 669 ms / 5,000 ms
コード長 725 bytes
コンパイル時間 3,532 ms
コンパイル使用メモリ 73,852 KB
実行使用メモリ 53,840 KB
最終ジャッジ日時 2023-08-14 13:38:12
合計ジャッジ時間 11,110 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 669 ms
53,840 KB
testcase_01 AC 123 ms
39,276 KB
testcase_02 AC 121 ms
39,788 KB
testcase_03 AC 122 ms
40,448 KB
testcase_04 AC 134 ms
40,116 KB
testcase_05 AC 136 ms
39,448 KB
testcase_06 AC 134 ms
39,556 KB
testcase_07 AC 134 ms
39,844 KB
testcase_08 AC 132 ms
39,952 KB
testcase_09 AC 131 ms
39,932 KB
testcase_10 AC 131 ms
40,056 KB
testcase_11 AC 132 ms
39,608 KB
testcase_12 AC 152 ms
40,024 KB
testcase_13 AC 136 ms
40,040 KB
testcase_14 AC 189 ms
41,192 KB
testcase_15 AC 156 ms
40,188 KB
testcase_16 AC 190 ms
40,816 KB
testcase_17 AC 189 ms
40,696 KB
testcase_18 AC 134 ms
39,584 KB
testcase_19 AC 180 ms
40,888 KB
testcase_20 AC 179 ms
40,628 KB
testcase_21 AC 548 ms
47,228 KB
testcase_22 AC 664 ms
52,936 KB
evil01.txt AC 669 ms
54,200 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