結果

問題 No.161 制限ジャンケン
ユーザー けむけむ
提出日時 2021-08-11 15:38:39
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 30 ms / 5,000 ms
コード長 804 bytes
コンパイル時間 212 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-09-25 02:26:35
合計ジャッジ時間 1,712 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

def janken(G, C, P, S):
    p = 0
    S = list(S)
    for i in range(len(S)):
        if (S[i] == 'G') and (P > 0):
            P -= 1
            p += 3
            S[i] = 0
        elif (S[i] == 'C') and (G > 0):
            G -= 1
            p += 3
            S[i] = 0
        elif (S[i] == 'P') and (C > 0):
            C -= 1
            p += 3
            S[i] = 0
    for s in S:
        if s == 0:
            continue
        elif (s == 'G') and (G > 0):
            G -= 1
            p += 1
        elif (s == 'C') and (C > 0):
            C -= 1
            p += 1
        elif (s == 'P') and (P > 0):
            P -= 1
            p += 1
    return p

def main():
    G, C, P = map(int, input().split())
    S = input()
    print(janken(G, C, P, S))

if __name__ == '__main__':
    main()
0