結果

問題 No.161 制限ジャンケン
ユーザー 🍡yurahuna🍡yurahuna
提出日時 2016-04-18 23:39:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 19 ms / 5,000 ms
コード長 476 bytes
コンパイル時間 79 ms
コンパイル使用メモリ 10,628 KB
実行使用メモリ 8,568 KB
最終ジャッジ日時 2023-08-20 04:50:10
合計ジャッジ時間 1,321 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,472 KB
testcase_01 AC 19 ms
8,412 KB
testcase_02 AC 18 ms
8,424 KB
testcase_03 AC 19 ms
8,568 KB
testcase_04 AC 19 ms
8,564 KB
testcase_05 AC 18 ms
8,392 KB
testcase_06 AC 18 ms
8,440 KB
testcase_07 AC 18 ms
8,472 KB
testcase_08 AC 19 ms
8,424 KB
testcase_09 AC 19 ms
8,444 KB
testcase_10 AC 19 ms
8,516 KB
testcase_11 AC 19 ms
8,428 KB
testcase_12 AC 19 ms
8,516 KB
testcase_13 AC 18 ms
8,440 KB
testcase_14 AC 18 ms
8,392 KB
testcase_15 AC 18 ms
8,396 KB
testcase_16 AC 18 ms
8,440 KB
testcase_17 AC 18 ms
8,516 KB
testcase_18 AC 19 ms
8,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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