結果

問題 No.161 制限ジャンケン
ユーザー nanaenanae
提出日時 2017-02-09 23:32:52
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 17 ms / 5,000 ms
コード長 1,168 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 11,024 KB
実行使用メモリ 8,396 KB
最終ジャッジ日時 2023-08-20 04:59:23
合計ジャッジ時間 1,249 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,308 KB
testcase_01 AC 16 ms
8,268 KB
testcase_02 AC 16 ms
8,232 KB
testcase_03 AC 16 ms
8,216 KB
testcase_04 AC 16 ms
8,360 KB
testcase_05 AC 16 ms
8,268 KB
testcase_06 AC 16 ms
8,276 KB
testcase_07 AC 16 ms
8,212 KB
testcase_08 AC 16 ms
7,816 KB
testcase_09 AC 16 ms
8,284 KB
testcase_10 AC 16 ms
8,220 KB
testcase_11 AC 17 ms
8,324 KB
testcase_12 AC 17 ms
7,920 KB
testcase_13 AC 16 ms
8,212 KB
testcase_14 AC 16 ms
8,332 KB
testcase_15 AC 16 ms
8,360 KB
testcase_16 AC 17 ms
8,396 KB
testcase_17 AC 16 ms
8,376 KB
testcase_18 AC 16 ms
8,236 KB
権限があれば一括ダウンロードができます

ソースコード

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