結果

問題 No.161 制限ジャンケン
ユーザー wotsushiwotsushi
提出日時 2017-01-24 21:14:32
言語 Ruby
(3.3.0)
結果
AC  
実行時間 85 ms / 5,000 ms
コード長 292 bytes
コンパイル時間 571 ms
コンパイル使用メモリ 11,236 KB
実行使用メモリ 15,296 KB
最終ジャッジ日時 2023-08-20 04:59:09
合計ジャッジ時間 3,267 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
15,112 KB
testcase_01 AC 85 ms
15,132 KB
testcase_02 AC 81 ms
15,128 KB
testcase_03 AC 79 ms
15,224 KB
testcase_04 AC 83 ms
15,252 KB
testcase_05 AC 80 ms
15,020 KB
testcase_06 AC 78 ms
15,020 KB
testcase_07 AC 79 ms
15,248 KB
testcase_08 AC 83 ms
15,168 KB
testcase_09 AC 82 ms
15,136 KB
testcase_10 AC 81 ms
15,284 KB
testcase_11 AC 80 ms
15,032 KB
testcase_12 AC 80 ms
15,260 KB
testcase_13 AC 80 ms
15,140 KB
testcase_14 AC 81 ms
15,296 KB
testcase_15 AC 79 ms
15,120 KB
testcase_16 AC 79 ms
15,144 KB
testcase_17 AC 80 ms
15,164 KB
testcase_18 AC 80 ms
15,140 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

G, C, P = gets.split.map(&:to_i)
S = gets.chomp
g, c, p = ["G", "C", "P"].map {|s| S.count(s)}
def f(a, b)
  return [a - b, 0].max
end
ans = 3 * [[G, c], [C, p], [P, g]].map(&:min).inject(:+) +
      [[f(G, c), f(g, P)], [f(C, p), f(c, G)], [f(P, g), f(p, C)]].map(&:min).inject(:+)
puts ans
0