結果

問題 No.161 制限ジャンケン
ユーザー d_nishiyama85d_nishiyama85
提出日時 2016-06-13 22:54:08
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 699 bytes
コンパイル時間 36 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-04-17 19:24:34
合計ジャッジ時間 2,089 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 75 ms
12,032 KB
testcase_02 AC 77 ms
12,288 KB
testcase_03 AC 71 ms
12,032 KB
testcase_04 WA -
testcase_05 AC 73 ms
11,904 KB
testcase_06 AC 72 ms
12,160 KB
testcase_07 AC 72 ms
12,288 KB
testcase_08 AC 76 ms
12,160 KB
testcase_09 AC 72 ms
11,904 KB
testcase_10 AC 72 ms
11,904 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 73 ms
11,904 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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