結果

問題 No.161 制限ジャンケン
ユーザー simansiman
提出日時 2015-04-03 00:47:16
言語 Ruby
(3.3.0)
結果
AC  
実行時間 87 ms / 5,000 ms
コード長 726 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 11,460 KB
実行使用メモリ 15,304 KB
最終ジャッジ日時 2023-08-20 04:27:12
合計ジャッジ時間 2,806 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,232 KB
testcase_01 AC 87 ms
15,144 KB
testcase_02 AC 82 ms
15,152 KB
testcase_03 AC 84 ms
15,132 KB
testcase_04 AC 80 ms
15,172 KB
testcase_05 AC 82 ms
15,140 KB
testcase_06 AC 83 ms
15,300 KB
testcase_07 AC 82 ms
15,152 KB
testcase_08 AC 82 ms
15,036 KB
testcase_09 AC 82 ms
15,176 KB
testcase_10 AC 81 ms
15,124 KB
testcase_11 AC 82 ms
15,148 KB
testcase_12 AC 81 ms
15,140 KB
testcase_13 AC 82 ms
15,076 KB
testcase_14 AC 83 ms
15,040 KB
testcase_15 AC 81 ms
15,196 KB
testcase_16 AC 81 ms
15,304 KB
testcase_17 AC 80 ms
15,088 KB
testcase_18 AC 81 ms
15,052 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Yukicoder
  def initialize
    goo, choki, par = gets.chomp.split(' ').map(&:to_i)
    enemy = Hash.new(0)
    s = gets.chomp.split('')

    s.each do |i|
      enemy[i] += 1
    end

    score = 0

    goo_win   = [goo, enemy['C']].min
    choki_win = [choki, enemy['P']].min
    par_win   = [par, enemy['G']].min

    score += 3 * (goo_win + choki_win + par_win)
    goo   -= goo_win
    choki -= choki_win
    par   -= par_win
    enemy['C'] -= goo_win
    enemy['P'] -= choki_win
    enemy['G'] -= par_win

    goo_draw    = [goo, enemy['G']].min
    choki_draw  = [choki, enemy['C']].min
    par_draw    = [par, enemy['P']].min

    score += goo_draw + choki_draw + par_draw

    puts score
  end
end

Yukicoder.new
0