結果

問題 No.406 鴨等間隔の法則
ユーザー Hiroaki KonoHiroaki Kono
提出日時 2017-10-29 17:34:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 524 ms / 2,000 ms
コード長 743 bytes
コンパイル時間 3,719 ms
コンパイル使用メモリ 81,356 KB
実行使用メモリ 69,872 KB
最終ジャッジ日時 2023-09-21 18:39:55
合計ジャッジ時間 16,751 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 340 ms
60,444 KB
testcase_01 AC 131 ms
56,180 KB
testcase_02 AC 129 ms
55,820 KB
testcase_03 AC 131 ms
55,552 KB
testcase_04 AC 493 ms
67,468 KB
testcase_05 AC 332 ms
59,632 KB
testcase_06 AC 335 ms
60,020 KB
testcase_07 AC 345 ms
60,028 KB
testcase_08 AC 478 ms
66,780 KB
testcase_09 AC 524 ms
69,808 KB
testcase_10 AC 343 ms
59,932 KB
testcase_11 AC 452 ms
66,492 KB
testcase_12 AC 366 ms
64,704 KB
testcase_13 AC 360 ms
62,032 KB
testcase_14 AC 462 ms
66,948 KB
testcase_15 AC 211 ms
57,388 KB
testcase_16 AC 221 ms
57,284 KB
testcase_17 AC 203 ms
57,064 KB
testcase_18 AC 229 ms
58,296 KB
testcase_19 AC 239 ms
59,652 KB
testcase_20 AC 249 ms
59,556 KB
testcase_21 AC 246 ms
59,204 KB
testcase_22 AC 294 ms
59,972 KB
testcase_23 AC 368 ms
64,196 KB
testcase_24 AC 449 ms
66,852 KB
testcase_25 AC 521 ms
69,872 KB
testcase_26 AC 517 ms
69,444 KB
testcase_27 AC 419 ms
68,996 KB
testcase_28 AC 437 ms
68,772 KB
testcase_29 AC 484 ms
69,472 KB
testcase_30 AC 514 ms
69,492 KB
testcase_31 AC 508 ms
69,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class No406 {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int count = s.nextInt();
        s.nextLine();
        int[] arr = Arrays.stream(s.nextLine().trim().split(" "))
            .mapToInt(Integer::parseInt)
            .toArray();
        Arrays.sort(arr);
        String out = "YES";
        int diff = arr[1] - arr[0];
        if (diff == 0) {
            out = "NO";
        } else {
            for (int i = 2; i < count; i++) {
                if (arr[i] - arr[i - 1] != diff) {
                    out = "NO";
                    break;
                }
            }
        }
        System.out.println(out);
    }
}
0