結果

問題 No.135 とりあえず1次元の問題
ユーザー matsuyoshi30matsuyoshi30
提出日時 2017-02-21 22:17:50
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 625 bytes
コンパイル時間 1,999 ms
コンパイル使用メモリ 72,588 KB
実行使用メモリ 62,252 KB
最終ジャッジ日時 2023-09-02 00:50:00
合計ジャッジ時間 8,571 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 553 ms
60,500 KB
testcase_01 AC 120 ms
55,628 KB
testcase_02 AC 121 ms
55,780 KB
testcase_03 WA -
testcase_04 AC 131 ms
55,820 KB
testcase_05 AC 129 ms
56,420 KB
testcase_06 AC 129 ms
55,828 KB
testcase_07 AC 129 ms
55,960 KB
testcase_08 AC 129 ms
55,964 KB
testcase_09 AC 128 ms
56,328 KB
testcase_10 AC 129 ms
56,000 KB
testcase_11 AC 129 ms
56,828 KB
testcase_12 AC 147 ms
56,536 KB
testcase_13 AC 128 ms
56,344 KB
testcase_14 AC 175 ms
56,528 KB
testcase_15 AC 141 ms
56,244 KB
testcase_16 AC 178 ms
56,080 KB
testcase_17 AC 174 ms
56,168 KB
testcase_18 AC 133 ms
56,120 KB
testcase_19 AC 177 ms
56,848 KB
testcase_20 AC 166 ms
54,784 KB
testcase_21 AC 492 ms
62,252 KB
testcase_22 AC 575 ms
61,796 KB
evil01.txt AC 519 ms
60,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] x = new int[n];
        for(int i=0; i<n; i++) {
            x[i] = in.nextInt();
        }
        Arrays.sort(x);

        int len = Integer.MAX_VALUE;
        for(int i=1; i<n; i++) {
            if(x[i] != x[i-1]) {
                len = Math.min(len, Math.abs(x[i] - x[i-1]));
            }
        }

        System.out.println(len);

        in.close();
    }
}
0