結果

問題 No.161 制限ジャンケン
ユーザー rlangevinrlangevin
提出日時 2023-01-15 16:05:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 214 ms / 5,000 ms
コード長 992 bytes
コンパイル時間 442 ms
コンパイル使用メモリ 86,912 KB
実行使用メモリ 100,752 KB
最終ジャッジ日時 2023-08-27 23:23:52
合計ジャッジ時間 4,232 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 159 ms
95,052 KB
testcase_01 AC 75 ms
75,344 KB
testcase_02 AC 75 ms
75,340 KB
testcase_03 AC 80 ms
77,828 KB
testcase_04 AC 70 ms
70,964 KB
testcase_05 AC 69 ms
70,916 KB
testcase_06 AC 181 ms
98,080 KB
testcase_07 AC 93 ms
83,412 KB
testcase_08 AC 214 ms
100,752 KB
testcase_09 AC 93 ms
78,756 KB
testcase_10 AC 135 ms
88,068 KB
testcase_11 AC 129 ms
87,424 KB
testcase_12 AC 126 ms
85,408 KB
testcase_13 AC 197 ms
99,236 KB
testcase_14 AC 143 ms
88,496 KB
testcase_15 AC 165 ms
94,656 KB
testcase_16 AC 133 ms
87,624 KB
testcase_17 AC 135 ms
88,300 KB
testcase_18 AC 137 ms
87,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

G, C, P = map(int, input().split())
S = list(input())
N = len(S)

inf = 10 ** 18
pre = [[-inf] * 305 for i in range(305)]
pre[0][0] = 0
for i in range(N):
    dp = [[-inf] * 305 for i in range(305)]
    for g in range(G + 1):
        for c in range(C + 1):
            p = i - g - c
            if p < 0 or P < p:
                continue
            if S[i] == "G":
                dp[g + 1][c] = max(dp[g + 1][c], pre[g][c] + 1)
                dp[g][c + 1] = max(dp[g][c + 1], pre[g][c])
                dp[g][c] = max(dp[g][c], pre[g][c] + 3)
            elif S[i] == "C":
                dp[g + 1][c] = max(dp[g + 1][c], pre[g][c] + 3)
                dp[g][c + 1] = max(dp[g][c + 1], pre[g][c] + 1)
                dp[g][c] = max(dp[g][c], pre[g][c])
            else:
                dp[g + 1][c] = max(dp[g + 1][c], pre[g][c])
                dp[g][c + 1] = max(dp[g][c + 1], pre[g][c] + 3)
                dp[g][c] = max(dp[g][c], pre[g][c] + 1)
    dp, pre= pre, dp
print(pre[G][C])
0