結果

問題 No.161 制限ジャンケン
ユーザー 👑 kmjpkmjp
提出日時 2015-09-19 10:53:03
言語 Python2
(2.7.18)
結果
AC  
実行時間 10 ms / 5,000 ms
コード長 935 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 6,944 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2024-05-07 12:09:36
合計ジャッジ時間 937 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
6,144 KB
testcase_01 AC 9 ms
6,016 KB
testcase_02 AC 9 ms
6,016 KB
testcase_03 AC 9 ms
6,016 KB
testcase_04 AC 9 ms
6,144 KB
testcase_05 AC 9 ms
6,016 KB
testcase_06 AC 9 ms
6,144 KB
testcase_07 AC 9 ms
6,016 KB
testcase_08 AC 10 ms
6,272 KB
testcase_09 AC 9 ms
5,888 KB
testcase_10 AC 9 ms
6,016 KB
testcase_11 AC 9 ms
6,144 KB
testcase_12 AC 9 ms
6,272 KB
testcase_13 AC 9 ms
6,144 KB
testcase_14 AC 9 ms
6,144 KB
testcase_15 AC 10 ms
6,144 KB
testcase_16 AC 9 ms
6,272 KB
testcase_17 AC 9 ms
6,016 KB
testcase_18 AC 9 ms
6,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-

G,C,P = map(int,raw_input().strip().split())
S = raw_input().strip()

# 相手の各手の数を数える
EG,EC,EP = 0,0,0
for i in range(len(S)):
    EG += S[i]=="G"
    EC += S[i]=="C"
    EP += S[i]=="P"

point = 0

# 勝てるところを勝つ。
# min(自分のグーの数, 相手のチョキの数)だけ相手のチョキにグーを出す。
# パー・チョキも同様
NG = min(G, EC); G -= NG; EC -= NG
NC = min(C, EP); C -= NC; EP -= NC
NP = min(P, EG); P -= NP; EG -= NP
point += 3*(NG+NC+NP)

# あいこに出来るところをあいこにする。
# min(自分のグーの数, 相手のグーの数)だけ相手のグーにグーを出す。
# パー・チョキも同様
NG = min(G, EG); G -= NG; EG -= NG
NC = min(C, EC); C -= NC; EC -= NC
NP = min(P, EP); P -= NP; EP -= NP
point += (NG+NC+NP)

# 残りは負けるだけで、どうせ0ポイントなので何もしない。
print point
0