結果
| 問題 |
No.161 制限ジャンケン
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-09-28 14:56:39 |
| 言語 | PHP (843.2) |
| 結果 |
AC
|
| 実行時間 | 43 ms / 5,000 ms |
| コード長 | 1,442 bytes |
| コンパイル時間 | 5,149 ms |
| コンパイル使用メモリ | 32,272 KB |
| 実行使用メモリ | 32,532 KB |
| 最終ジャッジ日時 | 2024-11-30 05:06:17 |
| 合計ジャッジ時間 | 6,738 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
コンパイルメッセージ
No syntax errors detected in Main.php
ソースコード
<?php
list($g, $c, $p) = explode(" ",trim(fgets(STDIN)));
$hands = array_count_values(str_split(trim(fgets(STDIN))));
$first = [];
$win = 0;
$even = 0;
foreach($hands as $hand => $times)
{
switch($hand)
{
case "G":
while($p && $times)
{
$times--;
$p--;
$win++;
}
$first["G"] = $times;
break;
case "C":
while($g && $times)
{
$times--;
$g--;
$win++;
}
$first["C"] = $times;
break;
case "P":
while($c && $times)
{
$times--;
$c--;
$win++;
}
$first["P"] = $times;
break;
}
}
foreach($first as $hand => $times)
{
switch($hand)
{
case "G":
while($g && $times)
{
$times--;
$g--;
$even++;
}
break;
case "C":
while($c && $times)
{
$times--;
$c--;
$even++;
}
break;
case "P":
while($p && $times)
{
$times--;
$p--;
$even++;
}
break;
}
}
echo $win*3+$even;
echo PHP_EOL;