結果

問題 No.161 制限ジャンケン
ユーザー 👑 horiesinitihoriesiniti
提出日時 2017-06-27 12:34:34
言語 Ruby
(3.3.0)
結果
AC  
実行時間 81 ms / 5,000 ms
コード長 341 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 11,580 KB
実行使用メモリ 15,336 KB
最終ジャッジ日時 2023-08-20 05:03:19
合計ジャッジ時間 2,922 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
15,144 KB
testcase_01 AC 79 ms
15,268 KB
testcase_02 AC 80 ms
15,336 KB
testcase_03 AC 79 ms
15,128 KB
testcase_04 AC 79 ms
15,120 KB
testcase_05 AC 78 ms
15,296 KB
testcase_06 AC 79 ms
15,176 KB
testcase_07 AC 79 ms
15,092 KB
testcase_08 AC 79 ms
15,240 KB
testcase_09 AC 78 ms
15,120 KB
testcase_10 AC 79 ms
15,208 KB
testcase_11 AC 81 ms
15,032 KB
testcase_12 AC 79 ms
15,252 KB
testcase_13 AC 79 ms
15,088 KB
testcase_14 AC 80 ms
15,240 KB
testcase_15 AC 80 ms
15,152 KB
testcase_16 AC 78 ms
15,044 KB
testcase_17 AC 78 ms
15,128 KB
testcase_18 AC 79 ms
15,076 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

h={"G"=>0,"C"=>0,"P"=>0}
g1,c1,p1=gets.split.map{|e| e.to_i}


gets.chomp.chars{|e|
	h[e]=h[e]+1
}
ans=0
d1=[h["G"],p1].min
d2=[h["P"],c1].min
d3=[h["C"],g1].min
ans=(d1+d2+d3)*3

p1=p1-d1
h["G"]=h["G"]-d1

c1=c1-d2
h["P"]=h["P"]-d2

g1=g1-d3
h["C"]=h["C"]-d3

ans=ans+[h["G"],g1].min
ans=ans+[h["P"],p1].min
ans=ans+[h["C"],c1].min
puts ans
0