結果

問題 No.161 制限ジャンケン
ユーザー brthyyjpbrthyyjp
提出日時 2021-04-12 18:41:43
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 882 bytes
コンパイル時間 776 ms
コンパイル使用メモリ 86,828 KB
実行使用メモリ 71,524 KB
最終ジャッジ日時 2023-09-11 00:55:17
合計ジャッジ時間 3,830 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 71 ms
71,520 KB
testcase_02 AC 72 ms
71,224 KB
testcase_03 AC 72 ms
71,136 KB
testcase_04 AC 72 ms
71,380 KB
testcase_05 AC 72 ms
71,268 KB
testcase_06 AC 70 ms
71,280 KB
testcase_07 AC 72 ms
71,440 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 72 ms
71,364 KB
testcase_11 AC 72 ms
70,988 KB
testcase_12 AC 73 ms
71,220 KB
testcase_13 WA -
testcase_14 AC 71 ms
71,260 KB
testcase_15 AC 72 ms
71,432 KB
testcase_16 AC 71 ms
71,312 KB
testcase_17 AC 69 ms
71,524 KB
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

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 = min(P0, G1), G1-min(P0, G1)
if C1:
    if C0 >= C1:
        C0 -= C1
        ans += C1
        C1 = 0
    else:
        ans += C0
        C1 -= C0
        P0 -= C1
        C0 = 0
        C1 = 0
if P1:
    if P0 >= P1:
        P0 -= P1
        ans += P1
        P1 = 0
    else:
        ans += P0
        P1 -= P0
        G0 -= P1
        P0 = 0
        P1 = 0
if G1:
    if G0 >= G1:
        G0 -= G1
        ans += G1
        G1 = 0
    else:
        ans += G0
        G1 -= G0
        C0 -= G1
        G0 = 0
        G1 = 0
print(ans)
0