結果

問題 No.135 とりあえず1次元の問題
ユーザー samplelpmassamplelpmas
提出日時 2016-11-08 03:15:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 689 ms / 5,000 ms
コード長 837 bytes
コンパイル時間 1,887 ms
コンパイル使用メモリ 71,448 KB
実行使用メモリ 67,128 KB
最終ジャッジ日時 2023-09-02 00:41:40
合計ジャッジ時間 8,839 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 673 ms
67,128 KB
testcase_01 AC 122 ms
55,932 KB
testcase_02 AC 120 ms
55,644 KB
testcase_03 AC 118 ms
56,072 KB
testcase_04 AC 129 ms
55,584 KB
testcase_05 AC 130 ms
55,824 KB
testcase_06 AC 131 ms
55,832 KB
testcase_07 AC 130 ms
55,780 KB
testcase_08 AC 129 ms
54,088 KB
testcase_09 AC 128 ms
55,508 KB
testcase_10 AC 129 ms
57,000 KB
testcase_11 AC 125 ms
56,124 KB
testcase_12 AC 153 ms
55,960 KB
testcase_13 AC 129 ms
55,668 KB
testcase_14 AC 178 ms
56,772 KB
testcase_15 AC 144 ms
55,668 KB
testcase_16 AC 180 ms
56,552 KB
testcase_17 AC 174 ms
56,908 KB
testcase_18 AC 130 ms
55,464 KB
testcase_19 AC 167 ms
56,784 KB
testcase_20 AC 172 ms
56,116 KB
testcase_21 AC 541 ms
62,560 KB
testcase_22 AC 689 ms
65,684 KB
evil01.txt AC 588 ms
63,528 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 numCoordinates = sc.nextInt();

        Integer[]  coordinatesX = new Integer[numCoordinates];

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

        Arrays.sort(coordinatesX);

        int distanceMin = Integer.MAX_VALUE;

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

            if (0 < (coordinatesX[i + 1] - coordinatesX[i])) {
                distanceMin = Math.min(distanceMin, coordinatesX[i + 1] - coordinatesX[i]);
            }

        }

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

        System.out.println(distanceMin);

    }

}
0