結果

問題 No.161 制限ジャンケン
ユーザー rpy3cpprpy3cpp
提出日時 2015-06-02 12:35:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 16 ms / 5,000 ms
コード長 1,159 bytes
コンパイル時間 79 ms
コンパイル使用メモリ 10,868 KB
実行使用メモリ 7,940 KB
最終ジャッジ日時 2023-08-20 04:31:29
合計ジャッジ時間 1,243 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,904 KB
testcase_01 AC 16 ms
7,880 KB
testcase_02 AC 16 ms
7,796 KB
testcase_03 AC 16 ms
7,792 KB
testcase_04 AC 16 ms
7,932 KB
testcase_05 AC 16 ms
7,784 KB
testcase_06 AC 16 ms
7,760 KB
testcase_07 AC 16 ms
7,940 KB
testcase_08 AC 16 ms
7,896 KB
testcase_09 AC 16 ms
7,836 KB
testcase_10 AC 16 ms
7,792 KB
testcase_11 AC 16 ms
7,808 KB
testcase_12 AC 15 ms
7,836 KB
testcase_13 AC 16 ms
7,936 KB
testcase_14 AC 16 ms
7,848 KB
testcase_15 AC 16 ms
7,784 KB
testcase_16 AC 16 ms
7,872 KB
testcase_17 AC 16 ms
7,868 KB
testcase_18 AC 16 ms
7,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def read_data():
    G, C, P = map(int, input().split())
    S = input()
    return G, C, P, S

def solve(G, C, P, S):
    ng = S.count('G')
    nc = S.count('C')
    np = S.count('P')
    score = 0

    # ng <- P
    if ng >= P:
        score += 3 * P
        ng -= P
        P = 0
    else:
        score += 3 * ng
        P -= ng
        ng = 0
    # nc <- G
    if nc >= G:
        score += 3 * G
        nc -= G
        G = 0
    else:
        score += 3 * nc
        G -= nc
        nc = 0
    # np <- C
    if np >= C:
        score += 3 * C
        np -= C
        C = 0
    else:
        score += 3 * np
        C -= np
        np = 0

    # ng <- G
    if ng >= G:
        score += G
        ng -= G
        G = 0
    else:
        score += ng
        G -= ng
        ng = 0
    # nc <- C
    if nc >= C:
        score += C
        nc -= C
        C = 0
    else:
        score += nc
        C -= nc
        nc = 0
    # np <- P
    if np >= P:
        score += P
        np -= P
        P = 0
    else:
        score += np
        P -= np
        np = 0

    return score

if __name__ == '__main__':
    param = read_data()
    print(solve(*param))
0