結果

問題 No.161 制限ジャンケン
ユーザー あかりき
提出日時 2021-03-01 18:32:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 41 ms / 5,000 ms
コード長 356 bytes
コンパイル時間 227 ms
コンパイル使用メモリ 82,700 KB
実行使用メモリ 52,352 KB
最終ジャッジ日時 2024-10-03 00:55:53
合計ジャッジ時間 1,824 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

g,c,p=map(int,input().split())
s=list(input())
g2=s.count('G')
c2=s.count('C')
p2=s.count('P')

ans=0

if p>=g2:
  ans+=g2*3
  p-=g2
  g2=0
else:
  ans+=p*3
  g2-=p
  p=0

if g>=c2:
  ans+=c2*3
  g-=c2
  c2=0
else:
  ans+=g*3
  c2-=g
  g=0

if c>=p2:
  ans+=p2*3
  c-=p2
  p2=0
else:
  ans+=c*3
  p2-=c
  c=0

ans+=min(g,g2)+min(c,c2)+min(p,p2)

print(ans)
0