結果

問題 No.161 制限ジャンケン
ユーザー takakintakakin
提出日時 2020-04-21 22:44:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 31 ms / 5,000 ms
コード長 406 bytes
コンパイル時間 235 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-17 19:39:04
合計ジャッジ時間 1,347 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,624 KB
testcase_01 AC 27 ms
10,624 KB
testcase_02 AC 24 ms
10,624 KB
testcase_03 AC 27 ms
10,752 KB
testcase_04 AC 25 ms
10,624 KB
testcase_05 AC 31 ms
10,624 KB
testcase_06 AC 27 ms
10,752 KB
testcase_07 AC 27 ms
10,624 KB
testcase_08 AC 27 ms
10,752 KB
testcase_09 AC 28 ms
10,624 KB
testcase_10 AC 25 ms
10,624 KB
testcase_11 AC 25 ms
10,624 KB
testcase_12 AC 27 ms
10,624 KB
testcase_13 AC 24 ms
10,624 KB
testcase_14 AC 25 ms
10,624 KB
testcase_15 AC 25 ms
10,624 KB
testcase_16 AC 27 ms
10,752 KB
testcase_17 AC 25 ms
10,624 KB
testcase_18 AC 26 ms
10,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
g,c,p=map(int,input().split())
S=input()
ans=0
gs,cs,ps=0,0,0
for s in S:
  if s=="G":
    gs+=1
  elif s=="C":
    cs+=1
  else:
    ps+=1
if gs>0 and p>0:
  w=min(gs,p)
  gs-=w
  p-=w
  ans+=3*w
if cs>0 and g>0:
  w=min(cs,g)
  cs-=w
  g-=w
  ans+=3*w
if ps>0 and c>0:
  w=min(ps,c)
  ps-=w
  c-=w
  ans+=3*w
print(ans+min(gs,g)+min(cs,c)+min(ps,p))
0