結果

問題 No.161 制限ジャンケン
コンテスト
ユーザー zombietan
提出日時 2016-05-29 02:37:34
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 94 ms / 5,000 ms
コード長 740 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 352 ms
コンパイル使用メモリ 20,820 KB
実行使用メモリ 15,488 KB
最終ジャッジ日時 2026-05-23 21:43:17
合計ジャッジ時間 3,368 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import deque
g, c, p = map(int, input().split())
S = input()
fg = S.count('G')
fc = S.count('C')
fp = S.count('P')
yuki = [g, c, p]
friend = [fc, fp, fg]

ans = 0
result_y = []
result_f = []
for j, k in zip(yuki, friend):
    if j > k:
        ans += k * 3
        result_y.append(j - k)
        result_f.append(0)
    elif k > j:
        ans += j * 3
        result_y.append(0)
        result_f.append(k - j)
    else:
        ans += j * 3
        result_y.append(0)
        result_f.append(0)
        
result_f = deque(result_f)       
result_f.rotate(1)
result_f = list(result_f)

for n, m in zip(result_y, result_f):
    if n > m:
        ans += m
    elif m > n:
        ans += n
    else:
        ans += n

print(ans)
0