結果

問題 No.161 制限ジャンケン
コンテスト
ユーザー 🍡yurahuna
提出日時 2016-04-18 23:39:38
言語 Python3
(3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 21 ms / 5,000 ms
+ 613µs
コード長 476 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 59 ms
コンパイル使用メモリ 14,976 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2026-10-02 09:54:13
合計ジャッジ時間 1,869 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import Counter

g1, c1, p1 = map(int, input().split())
s = Counter(input())
g2, c2, p2 = s['G'], s['C'], s['P']

ans = 0

# 勝ちに貪欲に割り当てる
d = min(g1, c2)
ans += 3 * d
g1 -= d
c2 -= d

d = min(c1, p2)
ans += 3 * d
c1 -= d
p2 -= d

d = min(p1, g2)
ans += 3 * d
p1 -= d
g2 -= d

# print(ans)
# print(g1, c1, p1)
# print(g2, c2, p2)

# あいこに貪欲に割り当てる
ans += min(g1, g2)
ans += min(c1, c2)
ans += min(p1, p2)


print(ans)
0