結果

問題 No.29 パワーアップ
ユーザー ayaaya
提出日時 2019-07-24 18:04:26
言語 PHP
(7.2.24)
結果
AC  
実行時間 15 ms / 5,000 ms
コード長 1,110 bytes
コンパイル時間 323 ms
使用メモリ 17,556 KB
最終ジャッジ日時 2023-01-27 15:40:46
合計ジャッジ時間 1,988 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 15 ms
17,340 KB
testcase_01 AC 15 ms
17,344 KB
testcase_02 AC 14 ms
17,408 KB
testcase_03 AC 14 ms
17,360 KB
testcase_04 AC 14 ms
17,556 KB
testcase_05 AC 15 ms
17,356 KB
testcase_06 AC 14 ms
17,456 KB
testcase_07 AC 14 ms
17,216 KB
testcase_08 AC 15 ms
17,424 KB
testcase_09 AC 14 ms
17,380 KB
testcase_10 AC 15 ms
17,380 KB
testcase_11 AC 15 ms
17,228 KB
testcase_12 AC 15 ms
17,324 KB
testcase_13 AC 15 ms
17,260 KB
testcase_14 AC 15 ms
17,352 KB
testcase_15 AC 14 ms
17,372 KB
testcase_16 AC 15 ms
17,168 KB
testcase_17 AC 15 ms
17,288 KB
testcase_18 AC 15 ms
17,484 KB
testcase_19 AC 14 ms
17,356 KB
testcase_20 AC 15 ms
17,396 KB
testcase_21 AC 15 ms
17,424 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