結果

問題 No.29 パワーアップ
ユーザー ayaaya
提出日時 2019-07-24 18:04:26
言語 PHP
(8.3.4)
結果
AC  
実行時間 16 ms / 5,000 ms
コード長 1,110 bytes
コンパイル時間 62 ms
コンパイル使用メモリ 18,764 KB
実行使用メモリ 18,864 KB
最終ジャッジ日時 2023-09-10 10:32:09
合計ジャッジ時間 2,428 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
18,700 KB
testcase_01 AC 15 ms
18,676 KB
testcase_02 AC 15 ms
18,680 KB
testcase_03 AC 15 ms
18,800 KB
testcase_04 AC 15 ms
18,668 KB
testcase_05 AC 15 ms
18,820 KB
testcase_06 AC 15 ms
18,676 KB
testcase_07 AC 16 ms
18,672 KB
testcase_08 AC 16 ms
18,628 KB
testcase_09 AC 15 ms
18,688 KB
testcase_10 AC 16 ms
18,824 KB
testcase_11 AC 16 ms
18,864 KB
testcase_12 AC 15 ms
18,796 KB
testcase_13 AC 15 ms
18,800 KB
testcase_14 AC 16 ms
18,816 KB
testcase_15 AC 15 ms
18,776 KB
testcase_16 AC 15 ms
18,708 KB
testcase_17 AC 15 ms
18,792 KB
testcase_18 AC 16 ms
18,664 KB
testcase_19 AC 16 ms
18,568 KB
testcase_20 AC 15 ms
18,660 KB
testcase_21 AC 15 ms
18,696 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
//No.29 パワーアップ

/*
Quinは、RPGをしている。
そのRPGでは、アイテムは10種類(それぞれ番号付けされている)あり、「同じアイテム」を2つ揃えるか、「任意のアイテム」を4つ揃えるとパワーアップする仕組みがある。
そして敵を倒したら、何かアイテムを3つもらうことができる。
(同じアイテムがもらえることもある。)
このとき、持てるアイテムの上限はないとし、アイテムの組み合わせは自由に決められる。(自動的にパワーアップすることはないとする。)

N回敵を倒すと考えたとき、その時のパワーアップする最大の回数を求めてください。
*/
$level=0;
$items=array_fill(1,10,0);
$N=trim(fgets(STDIN));
for($i=1;$i<=$N;$i++){
  $line=trim(fgets(STDIN));
  $getItems=explode(" ",$line);

  for($x=0;$x<=2;$x++){
  $items[$getItems[$x]] =$items[$getItems[$x]]+1;
  }
}
foreach($items as $key=>$value){
  $level=$level+floor($value/2);
}
$level=$level+floor(($N*3-($level*2))/4);
echo $level;
?>
0