結果

問題 No.135 とりあえず1次元の問題
コンテスト
ユーザー Hiroaki Kono
提出日時 2017-10-31 22:43:08
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 468 ms / 5,000 ms
コード長 725 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,570 ms
コンパイル使用メモリ 86,484 KB
実行使用メモリ 58,520 KB
最終ジャッジ日時 2026-05-16 13:32:15
合計ジャッジ時間 7,945 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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