結果

問題 No.161 制限ジャンケン
ユーザー けむけむけむけむ
提出日時 2021-08-11 15:38:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 29 ms / 5,000 ms
コード長 804 bytes
コンパイル時間 197 ms
コンパイル使用メモリ 11,872 KB
実行使用メモリ 10,136 KB
最終ジャッジ日時 2023-10-25 07:05:26
合計ジャッジ時間 1,552 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,136 KB
testcase_01 AC 29 ms
10,136 KB
testcase_02 AC 28 ms
10,136 KB
testcase_03 AC 29 ms
10,136 KB
testcase_04 AC 28 ms
10,136 KB
testcase_05 AC 29 ms
10,136 KB
testcase_06 AC 28 ms
10,136 KB
testcase_07 AC 28 ms
10,136 KB
testcase_08 AC 29 ms
10,136 KB
testcase_09 AC 29 ms
10,136 KB
testcase_10 AC 28 ms
10,136 KB
testcase_11 AC 28 ms
10,136 KB
testcase_12 AC 28 ms
10,136 KB
testcase_13 AC 28 ms
10,136 KB
testcase_14 AC 29 ms
10,136 KB
testcase_15 AC 29 ms
10,136 KB
testcase_16 AC 28 ms
10,136 KB
testcase_17 AC 28 ms
10,136 KB
testcase_18 AC 29 ms
10,136 KB
権限があれば一括ダウンロードができます

ソースコード

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