結果

問題 No.161 制限ジャンケン
ユーザー ntudantuda
提出日時 2024-01-01 18:32:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 36 ms / 5,000 ms
コード長 499 bytes
コンパイル時間 406 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 53,460 KB
最終ジャッジ日時 2024-01-01 18:32:46
合計ジャッジ時間 2,000 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

X = list(map(int,input().split()))
S = input()
dic = {"G":0,"C":1,"P":2}
Y = [0] * 3
for s in S:
    Y[dic[s]] += 1
ans = 0
for i in range(3):
    i2 = (i+1) % 3
    if X[i] >= Y[i2]:
        ans += 3 * Y[i2]
        X[i] -= Y[i2]
        Y[i2] = 0
    else:
        ans += 3 * X[i]
        Y[i2] -= X[i]
        X[i] = 0
for i in range(3):
    if X[i] >= Y[i]:
        ans += Y[i]
        X[i] -= Y[i]
        Y[i] = 0
    else:
        ans += X[i]
        Y[i] -= X[i]
        X[i] = 0
print(ans)
0