結果

問題 No.29 パワーアップ
ユーザー tazakkytazakky
提出日時 2017-09-08 21:40:31
言語 PHP
(7.2.24)
結果
AC  
実行時間 16 ms / 5,000 ms
コード長 730 bytes
コンパイル時間 461 ms
使用メモリ 17,524 KB
最終ジャッジ日時 2022-12-13 09:28:54
合計ジャッジ時間 2,355 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 14 ms
17,096 KB
testcase_01 AC 14 ms
17,248 KB
testcase_02 AC 16 ms
17,524 KB
testcase_03 AC 16 ms
17,248 KB
testcase_04 AC 15 ms
17,324 KB
testcase_05 AC 15 ms
17,376 KB
testcase_06 AC 16 ms
17,400 KB
testcase_07 AC 15 ms
17,328 KB
testcase_08 AC 15 ms
17,080 KB
testcase_09 AC 15 ms
17,060 KB
testcase_10 AC 15 ms
17,436 KB
testcase_11 AC 16 ms
17,404 KB
testcase_12 AC 15 ms
17,232 KB
testcase_13 AC 15 ms
17,116 KB
testcase_14 AC 15 ms
17,404 KB
testcase_15 AC 16 ms
17,124 KB
testcase_16 AC 15 ms
17,236 KB
testcase_17 AC 15 ms
17,328 KB
testcase_18 AC 15 ms
17,268 KB
testcase_19 AC 15 ms
17,128 KB
testcase_20 AC 15 ms
17,424 KB
testcase_21 AC 16 ms
17,120 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