結果

問題 No.406 鴨等間隔の法則
ユーザー papinianuspapinianus
提出日時 2016-08-23 09:32:02
言語 PHP
(8.3.4)
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 478 bytes
コンパイル時間 938 ms
コンパイル使用メモリ 18,472 KB
実行使用メモリ 37,268 KB
最終ジャッジ日時 2023-09-21 18:03:20
合計ジャッジ時間 3,834 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
26,960 KB
testcase_01 AC 14 ms
18,680 KB
testcase_02 AC 15 ms
18,892 KB
testcase_03 AC 15 ms
18,844 KB
testcase_04 AC 28 ms
37,200 KB
testcase_05 AC 20 ms
26,964 KB
testcase_06 AC 20 ms
26,956 KB
testcase_07 AC 19 ms
26,928 KB
testcase_08 AC 28 ms
37,116 KB
testcase_09 AC 28 ms
37,264 KB
testcase_10 AC 20 ms
26,872 KB
testcase_11 AC 26 ms
37,268 KB
testcase_12 AC 21 ms
27,012 KB
testcase_13 AC 20 ms
26,952 KB
testcase_14 AC 143 ms
37,248 KB
testcase_15 AC 15 ms
18,840 KB
testcase_16 AC 21 ms
18,884 KB
testcase_17 AC 17 ms
18,864 KB
testcase_18 AC 20 ms
18,888 KB
testcase_19 AC 25 ms
20,884 KB
testcase_20 AC 31 ms
20,860 KB
testcase_21 AC 28 ms
20,868 KB
testcase_22 AC 47 ms
25,044 KB
testcase_23 AC 21 ms
26,968 KB
testcase_24 AC 127 ms
35,152 KB
testcase_25 AC 29 ms
37,000 KB
testcase_26 AC 170 ms
37,180 KB
testcase_27 AC 23 ms
28,976 KB
testcase_28 AC 28 ms
37,200 KB
testcase_29 AC 173 ms
37,212 KB
testcase_30 AC 171 ms
37,216 KB
testcase_31 AC 28 ms
37,016 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
$n = trim(fgets(STDIN));
$birds = explode(" ", trim(fgets(STDIN)));
$flag = false;
$diff = 0;
if(count(array_unique($birds)) == $n) {
    $flag = true;
    rsort($birds);
    $prev = array_shift($birds);
    foreach($birds as $bird) {
        if(($diff == 0 ) || ($prev - $bird) == $diff) {
            $diff = $prev - $bird;
            $prev = $bird;
        } else {
            $flag = false;
            break;
        }
    }
}
echo ($flag)?"YES":"NO";
echo PHP_EOL;
0