結果

問題 No.161 制限ジャンケン
ユーザー 👑 kmjpkmjp
提出日時 2015-02-02 02:18:50
言語 Python2
(2.7.18)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 927 bytes
コンパイル時間 534 ms
コンパイル使用メモリ 7,116 KB
実行使用メモリ 6,100 KB
最終ジャッジ日時 2023-08-20 04:19:36
合計ジャッジ時間 1,786 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
5,924 KB
testcase_01 AC 11 ms
5,944 KB
testcase_02 AC 11 ms
5,856 KB
testcase_03 AC 10 ms
5,948 KB
testcase_04 AC 10 ms
5,944 KB
testcase_05 AC 11 ms
5,908 KB
testcase_06 AC 11 ms
6,028 KB
testcase_07 AC 11 ms
6,100 KB
testcase_08 AC 11 ms
6,092 KB
testcase_09 AC 11 ms
5,924 KB
testcase_10 AC 11 ms
6,000 KB
testcase_11 AC 12 ms
5,928 KB
testcase_12 AC 11 ms
5,896 KB
testcase_13 AC 11 ms
5,948 KB
testcase_14 AC 11 ms
6,032 KB
testcase_15 AC 11 ms
5,836 KB
testcase_16 AC 11 ms
5,868 KB
testcase_17 AC 11 ms
5,864 KB
testcase_18 AC 11 ms
5,896 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