結果

問題 No.161 制限ジャンケン
ユーザー d_nishiyama85
提出日時 2016-06-13 22:44:35
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 699 bytes
コンパイル時間 115 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-10-09 13:18:38
合計ジャッジ時間 2,633 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7 WA * 9
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

g, c, p = gets.strip.split.map{|e| e.to_i}
hands = {G:g, C:c, P:p}
s = gets.strip
score = 0
s.each_char { |chr|
  case chr
  when 'P'
    if hands[:C] > 0
      score += 3
      hands[:C] -= 1
    elsif hands[:P] > 0
      score += 1
      hands[:P] -= 1
    elsif hands[:G] > 0
      hands[:G] -= 1
    end

  when 'C'
    if hands[:G] > 0
      score += 3
      hands[:G] -= 1
    elsif hands[:C] > 0
      score += 1
      hands[:C] -= 1
    elsif hands[:G] > 0
      hands[:P] -= 1
    end

  when 'G'
    if hands[:P] > 0
      score += 3
      hands[:P] -= 1
    elsif hands[:G] > 0
      score += 1
      hands[:G] -= 1
    elsif hands[:C] > 0
      hands[:C] -= 1
    end
  end
}

puts score
0