結果

問題 No.29 パワーアップ
ユーザー tazakkytazakky
提出日時 2017-09-08 21:40:31
言語 PHP
(8.3.4)
結果
AC  
実行時間 42 ms / 5,000 ms
コード長 730 bytes
コンパイル時間 4,091 ms
コンパイル使用メモリ 30,628 KB
実行使用メモリ 31,268 KB
最終ジャッジ日時 2024-04-24 20:23:15
合計ジャッジ時間 6,061 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
31,140 KB
testcase_01 AC 42 ms
31,112 KB
testcase_02 AC 41 ms
30,832 KB
testcase_03 AC 40 ms
31,220 KB
testcase_04 AC 41 ms
30,968 KB
testcase_05 AC 40 ms
30,944 KB
testcase_06 AC 41 ms
30,988 KB
testcase_07 AC 40 ms
31,228 KB
testcase_08 AC 40 ms
31,052 KB
testcase_09 AC 40 ms
30,776 KB
testcase_10 AC 41 ms
31,060 KB
testcase_11 AC 42 ms
31,164 KB
testcase_12 AC 41 ms
31,020 KB
testcase_13 AC 41 ms
31,000 KB
testcase_14 AC 42 ms
30,972 KB
testcase_15 AC 40 ms
31,004 KB
testcase_16 AC 42 ms
31,072 KB
testcase_17 AC 40 ms
31,160 KB
testcase_18 AC 41 ms
30,912 KB
testcase_19 AC 41 ms
31,268 KB
testcase_20 AC 40 ms
31,048 KB
testcase_21 AC 42 ms
31,240 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
    // 1行目に敵を倒す回数を表すN (1<=N<=100)
    $n = trim(fgets(STDIN));
    // 2行目以降はi(1<=i<=N)回目で敵を倒した時のもらえる3つのアイテムの番号ai,bi,ci(1<=ai,bi,ci<=10)
    $items = array();
    for($i = 0; $i < $n; $i++){
        $item = explode(" ", trim(fgets(STDIN)));
        $items = array_merge($items, $item);
    }
    //print_r($items);
    $up = 0;
    $check = array();
    foreach ($items as $value) {
        if(in_array($value, $check)){
            $up++;
            $key = array_search($value, $check);
            unset($check[$key]);
        }else{
            $check[] = $value;
        }
    }
    echo $up + floor(count($check) / 4)."\n";

    
?>
0