結果

問題 No.161 制限ジャンケン
ユーザー HachimoriHachimori
提出日時 2015-03-05 23:28:01
言語 Python2
(2.7.18)
結果
AC  
実行時間 16 ms / 5,000 ms
コード長 592 bytes
コンパイル時間 74 ms
コンパイル使用メモリ 6,500 KB
実行使用メモリ 6,152 KB
最終ジャッジ日時 2023-08-20 04:20:19
合計ジャッジ時間 1,316 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,028 KB
testcase_01 AC 12 ms
5,940 KB
testcase_02 AC 11 ms
5,948 KB
testcase_03 AC 12 ms
6,060 KB
testcase_04 AC 12 ms
6,024 KB
testcase_05 AC 11 ms
5,848 KB
testcase_06 AC 12 ms
5,940 KB
testcase_07 AC 11 ms
5,944 KB
testcase_08 AC 12 ms
6,152 KB
testcase_09 AC 12 ms
5,944 KB
testcase_10 AC 12 ms
5,868 KB
testcase_11 AC 11 ms
5,884 KB
testcase_12 AC 11 ms
6,000 KB
testcase_13 AC 11 ms
5,868 KB
testcase_14 AC 11 ms
5,848 KB
testcase_15 AC 11 ms
6,140 KB
testcase_16 AC 11 ms
5,912 KB
testcase_17 AC 16 ms
5,872 KB
testcase_18 AC 12 ms
6,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python
#coding:utf8


def read():
    selfN = map(int, raw_input().split())
    s = raw_input()
    return selfN, s


def work((selfN, s)):
    oppN = [0, 0, 0]
    for ch in s:
        oppN["GCP".find(ch)] += 1
    
    ans = 0

    # win
    for i in range(3):
        n = min(selfN[i], oppN[(i + 1) % 3])
        ans += n * 3
        selfN[i] -= n
        oppN[(i + 1) % 3] -= n

    # draw
    for i in range(3):
        n = min(selfN[i], oppN[i])
        ans += n
        selfN[i] -= n
        oppN[i] -= n

    print ans
    

if __name__ == "__main__":
    work(read())
0