結果

問題 No.161 制限ジャンケン
ユーザー nanae
提出日時 2017-02-09 23:32:52
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 33 ms / 5,000 ms
コード長 1,168 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-11-30 05:08:17
合計ジャッジ時間 1,435 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    gcp_y = [int(i) for i in input().split()]
    gcp_em = [0, 0, 0]
    hands = input().rstrip()

    for hand in hands:
        if hand == 'G':
            gcp_em[0] += 1
        elif hand == 'C':
            gcp_em[1] += 1
        else:
            gcp_em[2] += 1

    score = 0

    kati = 0
    for i in range(3):
        if gcp_y[i] > gcp_em[(i + 1) % 3]:
            kati += gcp_em[(i + 1) % 3]
            gcp_y[i] -= gcp_em[(i + 1) % 3]
            gcp_em[(i + 1) % 3] = 0
        else:
            kati += gcp_y[i]
            gcp_em[(i + 1) % 3] -= gcp_y[i]
            gcp_y[i] = 0

    score += kati * 3

    aiko = 0
    for i in range(3):
        if gcp_y[i] > gcp_em[i]:
            aiko += gcp_em[i]
            gcp_y[i] -= gcp_em[i]
            gcp_em[(i + 1) % 3] = 0
        else:
            aiko += gcp_y[i]
            gcp_em[i] -= gcp_y[i]
            gcp_y[i] = 0

    score += aiko * 1

    print(score)

if __name__ == '__main__':
    solve()
0