結果

問題 No.29 パワーアップ
ユーザー beatdjambeatdjam
提出日時 2016-09-30 09:57:28
言語 PHP
(8.3.4)
結果
AC  
実行時間 16 ms / 5,000 ms
コード長 874 bytes
コンパイル時間 213 ms
コンパイル使用メモリ 18,660 KB
実行使用メモリ 19,004 KB
最終ジャッジ日時 2023-08-13 15:20:08
合計ジャッジ時間 1,669 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
18,756 KB
testcase_01 AC 16 ms
18,864 KB
testcase_02 AC 16 ms
19,004 KB
testcase_03 AC 15 ms
18,756 KB
testcase_04 AC 16 ms
18,836 KB
testcase_05 AC 15 ms
18,824 KB
testcase_06 AC 15 ms
18,568 KB
testcase_07 AC 15 ms
18,748 KB
testcase_08 AC 15 ms
18,756 KB
testcase_09 AC 16 ms
18,708 KB
testcase_10 AC 15 ms
18,892 KB
testcase_11 AC 15 ms
18,588 KB
testcase_12 AC 15 ms
18,792 KB
testcase_13 AC 15 ms
18,756 KB
testcase_14 AC 15 ms
18,816 KB
testcase_15 AC 15 ms
18,856 KB
testcase_16 AC 16 ms
18,704 KB
testcase_17 AC 15 ms
18,724 KB
testcase_18 AC 15 ms
18,840 KB
testcase_19 AC 15 ms
18,860 KB
testcase_20 AC 15 ms
18,568 KB
testcase_21 AC 15 ms
18,832 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
    $input_lines = trim(fgets(STDIN));
    $input_lines = str_replace(array("\r\n","\r","\n"), "", $input_lines);
    do {
        $tmpStr[] = $input_lines;
        $input_lines = trim(fgets(STDIN));
        $input_lines = str_replace(array("\r\n","\r","\n"), "", $input_lines);
    } while ($input_lines !== "");
    
    $items = [1  => 0,
    		  2  => 0,
    		  3  => 0,
    		  4  => 0,
    		  5  => 0,
    		  6  => 0,
    		  7  => 0,
    		  8  => 0,
    		  9  => 0,
    		  10 => 0];
    array_shift($tmpStr);
	
    foreach($tmpStr as $value){
    	$s = explode(" ", $value);
    	foreach($s as $value2){
    		$items[$value2] += 1;
    	}
    }
    
    $power = 0;
    $tmpCnt = 0;
    foreach($items as $key => $value){
    	$power += floor($value / 2);
    	$tmpCnt += ($value - floor($value / 2) * 2);
    } 
    echo $power + floor($tmpCnt / 4);
    
0