結果

問題 No.116 門松列(1)
ユーザー papinianuspapinianus
提出日時 2016-07-25 10:19:59
言語 PHP
(8.3.4)
結果
AC  
実行時間 16 ms / 5,000 ms
コード長 470 bytes
コンパイル時間 471 ms
コンパイル使用メモリ 18,488 KB
実行使用メモリ 18,992 KB
最終ジャッジ日時 2023-09-07 06:58:35
合計ジャッジ時間 1,916 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
18,720 KB
testcase_01 AC 16 ms
18,804 KB
testcase_02 AC 16 ms
18,772 KB
testcase_03 AC 15 ms
18,924 KB
testcase_04 AC 15 ms
18,800 KB
testcase_05 AC 16 ms
18,820 KB
testcase_06 AC 16 ms
18,796 KB
testcase_07 AC 16 ms
18,864 KB
testcase_08 AC 16 ms
18,780 KB
testcase_09 AC 15 ms
18,772 KB
testcase_10 AC 16 ms
18,884 KB
testcase_11 AC 15 ms
18,856 KB
testcase_12 AC 16 ms
18,836 KB
testcase_13 AC 16 ms
18,852 KB
testcase_14 AC 15 ms
18,720 KB
testcase_15 AC 15 ms
18,832 KB
testcase_16 AC 16 ms
18,880 KB
testcase_17 AC 16 ms
18,904 KB
testcase_18 AC 16 ms
18,720 KB
testcase_19 AC 16 ms
18,788 KB
testcase_20 AC 16 ms
18,928 KB
testcase_21 AC 16 ms
18,788 KB
testcase_22 AC 16 ms
18,748 KB
testcase_23 AC 16 ms
18,992 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
$null = trim(fgets(STDIN));
$bamboos = explode(" ", trim(fgets(STDIN)));
$size = count($bamboos);
$ans = 0;
for($i = 0; $i < $size-2; $i++) {
    if(isKadomatsu(array_slice($bamboos, $i, 3))) {
        $ans++;
    }
}
echo $ans;
echo PHP_EOL;

function isKadomatsu($arr) {
    if(count(array_unique($arr)) == 3) {
        if(array_keys($arr, max($arr))[0] == 1 || array_keys($arr, min($arr))[0] == 1 ) {
            return true;
        }
    }
    return false;
}
0