結果

問題 No.161 制限ジャンケン
ユーザー papinianuspapinianus
提出日時 2016-09-28 14:56:39
言語 PHP
(8.3.4)
結果
AC  
実行時間 17 ms / 5,000 ms
コード長 1,442 bytes
コンパイル時間 1,571 ms
コンパイル使用メモリ 18,488 KB
実行使用メモリ 18,992 KB
最終ジャッジ日時 2023-08-20 04:57:08
合計ジャッジ時間 3,260 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
18,812 KB
testcase_01 AC 16 ms
18,900 KB
testcase_02 AC 16 ms
18,940 KB
testcase_03 AC 15 ms
18,992 KB
testcase_04 AC 15 ms
18,932 KB
testcase_05 AC 16 ms
18,892 KB
testcase_06 AC 16 ms
18,872 KB
testcase_07 AC 15 ms
18,932 KB
testcase_08 AC 16 ms
18,880 KB
testcase_09 AC 16 ms
18,876 KB
testcase_10 AC 15 ms
18,872 KB
testcase_11 AC 16 ms
18,876 KB
testcase_12 AC 16 ms
18,908 KB
testcase_13 AC 16 ms
18,932 KB
testcase_14 AC 16 ms
18,900 KB
testcase_15 AC 16 ms
18,764 KB
testcase_16 AC 16 ms
18,868 KB
testcase_17 AC 15 ms
18,944 KB
testcase_18 AC 17 ms
18,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?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;
0