結果

問題 No.161 制限ジャンケン
ユーザー brthyyjpbrthyyjp
提出日時 2021-04-12 18:47:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 80 ms / 5,000 ms
コード長 568 bytes
コンパイル時間 446 ms
コンパイル使用メモリ 87,192 KB
実行使用メモリ 71,596 KB
最終ジャッジ日時 2023-09-11 01:00:06
合計ジャッジ時間 3,386 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
71,284 KB
testcase_01 AC 78 ms
71,596 KB
testcase_02 AC 77 ms
71,296 KB
testcase_03 AC 79 ms
71,340 KB
testcase_04 AC 80 ms
71,596 KB
testcase_05 AC 76 ms
71,148 KB
testcase_06 AC 76 ms
71,296 KB
testcase_07 AC 77 ms
71,492 KB
testcase_08 AC 76 ms
71,424 KB
testcase_09 AC 77 ms
71,284 KB
testcase_10 AC 76 ms
71,452 KB
testcase_11 AC 77 ms
71,280 KB
testcase_12 AC 77 ms
71,456 KB
testcase_13 AC 77 ms
71,140 KB
testcase_14 AC 77 ms
71,452 KB
testcase_15 AC 78 ms
71,316 KB
testcase_16 AC 76 ms
71,148 KB
testcase_17 AC 74 ms
71,148 KB
testcase_18 AC 76 ms
71,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

G0, C0, P0 = map(int, input().split())
S = str(input())
G1, C1, P1 = 0, 0, 0
for c in S:
    if c == 'G':
        G1 += 1
    elif c == 'C':
        C1 += 1
    else:
        P1 += 1
ans = 0
ans += min(G0, C1)*3
G0, C1 = G0-min(G0, C1), C1-min(G0, C1)

ans += min(C0, P1)*3
C0, P1 = C0-min(C0, P1), P1-min(C0, P1)

ans += min(P0, G1)*3
P0, G1 = P0-min(P0, G1), G1-min(P0, G1)

ans += min(G0, G1)
G0, G1 = G0-min(G0, G1), G1-min(G0, G1)

ans += min(C0, C1)
C0, C1 = C0-min(C0, C1), C1-min(C0, C1)

ans += min(P0, P1)
P0, P1 = P0-min(P0, P1), P1-min(P0, P1)

print(ans)
0