結果

問題 No.406 鴨等間隔の法則
ユーザー Hiroaki KonoHiroaki Kono
提出日時 2017-10-29 17:36:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 601 ms / 2,000 ms
コード長 713 bytes
コンパイル時間 3,009 ms
コンパイル使用メモリ 72,444 KB
実行使用メモリ 63,088 KB
最終ジャッジ日時 2023-09-21 18:40:24
合計ジャッジ時間 17,914 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 425 ms
60,752 KB
testcase_01 AC 120 ms
56,192 KB
testcase_02 AC 120 ms
53,984 KB
testcase_03 AC 121 ms
55,752 KB
testcase_04 AC 579 ms
60,692 KB
testcase_05 AC 398 ms
60,300 KB
testcase_06 AC 403 ms
60,800 KB
testcase_07 AC 414 ms
58,636 KB
testcase_08 AC 547 ms
60,808 KB
testcase_09 AC 601 ms
58,840 KB
testcase_10 AC 428 ms
60,576 KB
testcase_11 AC 523 ms
59,148 KB
testcase_12 AC 450 ms
60,548 KB
testcase_13 AC 463 ms
60,720 KB
testcase_14 AC 532 ms
60,748 KB
testcase_15 AC 205 ms
59,084 KB
testcase_16 AC 237 ms
61,576 KB
testcase_17 AC 202 ms
58,592 KB
testcase_18 AC 240 ms
60,404 KB
testcase_19 AC 253 ms
61,888 KB
testcase_20 AC 277 ms
60,644 KB
testcase_21 AC 288 ms
60,572 KB
testcase_22 AC 338 ms
60,224 KB
testcase_23 AC 466 ms
60,736 KB
testcase_24 AC 512 ms
60,944 KB
testcase_25 AC 600 ms
60,940 KB
testcase_26 AC 562 ms
61,952 KB
testcase_27 AC 529 ms
60,624 KB
testcase_28 AC 514 ms
61,144 KB
testcase_29 AC 584 ms
63,088 KB
testcase_30 AC 575 ms
60,568 KB
testcase_31 AC 558 ms
60,644 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();
        int[] arr = new int[count];
        for (int i = 0; i < count; i++) {
            arr[i] = s.nextInt();
        }
        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