結果

問題 No.29 パワーアップ
ユーザー
提出日時 2016-01-20 22:23:53
言語 PHP
(8.3.4)
結果
AC  
実行時間 46 ms / 5,000 ms
コード長 1,050 bytes
コンパイル時間 123 ms
コンパイル使用メモリ 32,732 KB
実行使用メモリ 32,856 KB
最終ジャッジ日時 2023-10-21 13:37:06
合計ジャッジ時間 2,113 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
32,856 KB
testcase_01 AC 45 ms
32,856 KB
testcase_02 AC 43 ms
32,856 KB
testcase_03 AC 44 ms
32,856 KB
testcase_04 AC 43 ms
32,856 KB
testcase_05 AC 43 ms
32,856 KB
testcase_06 AC 43 ms
32,856 KB
testcase_07 AC 43 ms
32,856 KB
testcase_08 AC 42 ms
32,856 KB
testcase_09 AC 46 ms
32,856 KB
testcase_10 AC 43 ms
32,856 KB
testcase_11 AC 42 ms
32,856 KB
testcase_12 AC 42 ms
32,856 KB
testcase_13 AC 43 ms
32,856 KB
testcase_14 AC 43 ms
32,856 KB
testcase_15 AC 43 ms
32,856 KB
testcase_16 AC 43 ms
32,856 KB
testcase_17 AC 44 ms
32,856 KB
testcase_18 AC 44 ms
32,856 KB
testcase_19 AC 43 ms
32,856 KB
testcase_20 AC 43 ms
32,856 KB
testcase_21 AC 43 ms
32,856 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php

$input = trim(fgets(STDIN));

for($j =1; $j <=10; $j ++){
    $itemList[$j] = 0;
}

for($i = 1; $i <= $input; $i ++){
    $inputItem = trim(fgets(STDIN));
    $explode = explode(" ", $inputItem);
    foreach($explode as $explodeKey => $explodeValue){
        foreach($itemList as $itemListKey => $itemListValue){
            if($explodeValue == $itemListKey){
                $itemList[$explodeValue] ++;
            }
        }
    }
}

$answerCount = 0;
$answerAmari = 0;

for($p = 1; $p <= 10; $p ++){
    $itemListAnswer = floor($itemList[$p] / 2);
    if($itemList[$p] % 2 !== 0){
       $answerCount += $itemListAnswer;
       $answerAmari += $itemList[$p] - ($itemListAnswer * 2);
    }else if($itemListAnswer >= 1){
       $answerCount += $itemListAnswer;
    }else if($itemListAnswer <= 0){
       $itemListAmariAnswer = floor($itemList[$p] % 2);
       $answerAmari += $itemListAmariAnswer;
    }else{
       $answerAmari += 1;
    }
}

$answerAmari4 = floor($answerAmari / 4);
$answerCount += $answerAmari4;

echo $answerCount."\n";
0