結果

問題 No.406 鴨等間隔の法則
ユーザー fkwnw3_1243fkwnw3_1243
提出日時 2017-05-03 14:35:57
言語 Java19
(openjdk 21)
結果
AC  
実行時間 338 ms / 2,000 ms
コード長 1,003 bytes
コンパイル時間 2,545 ms
コンパイル使用メモリ 77,756 KB
実行使用メモリ 63,084 KB
最終ジャッジ日時 2023-09-21 18:28:11
合計ジャッジ時間 11,286 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 215 ms
57,384 KB
testcase_01 AC 60 ms
50,752 KB
testcase_02 AC 60 ms
50,752 KB
testcase_03 AC 61 ms
50,616 KB
testcase_04 AC 287 ms
62,456 KB
testcase_05 AC 199 ms
57,220 KB
testcase_06 AC 203 ms
57,412 KB
testcase_07 AC 202 ms
57,124 KB
testcase_08 AC 281 ms
62,136 KB
testcase_09 AC 287 ms
62,900 KB
testcase_10 AC 210 ms
57,616 KB
testcase_11 AC 267 ms
62,716 KB
testcase_12 AC 225 ms
57,132 KB
testcase_13 AC 210 ms
57,500 KB
testcase_14 AC 283 ms
62,484 KB
testcase_15 AC 98 ms
53,600 KB
testcase_16 AC 106 ms
54,332 KB
testcase_17 AC 86 ms
53,164 KB
testcase_18 AC 108 ms
53,560 KB
testcase_19 AC 119 ms
54,160 KB
testcase_20 AC 140 ms
54,164 KB
testcase_21 AC 142 ms
54,680 KB
testcase_22 AC 174 ms
57,528 KB
testcase_23 AC 231 ms
57,600 KB
testcase_24 AC 261 ms
62,292 KB
testcase_25 AC 282 ms
60,744 KB
testcase_26 AC 338 ms
62,968 KB
testcase_27 AC 240 ms
62,428 KB
testcase_28 AC 251 ms
62,096 KB
testcase_29 AC 294 ms
63,084 KB
testcase_30 AC 294 ms
62,464 KB
testcase_31 AC 292 ms
62,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.stream.Stream;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        int N = Integer.parseInt(reader.readLine());
        String[] inputs = reader.readLine().split(" ");
        int[] positions = Stream.of(inputs).mapToInt(Integer::parseInt).toArray();

        Arrays.sort(positions);
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        for (int i = 1; i < N; i++) {
            int differences = positions[i] - positions[i - 1];
            max = Math.max(max, differences);
            min = Math.min(min, differences);
        }

        if (max == min && min != 0) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}
0