結果

問題 No.161 制限ジャンケン
ユーザー zeroyonichihachizeroyonichihachi
提出日時 2016-10-31 16:01:41
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 446 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,544 KB
最終ジャッジ日時 2024-05-03 20:08:04
合計ジャッジ時間 2,804 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 90 ms
11,904 KB
testcase_02 AC 89 ms
12,160 KB
testcase_03 AC 88 ms
12,160 KB
testcase_04 WA -
testcase_05 AC 94 ms
12,032 KB
testcase_06 AC 88 ms
12,160 KB
testcase_07 AC 90 ms
12,160 KB
testcase_08 AC 92 ms
12,032 KB
testcase_09 AC 90 ms
12,160 KB
testcase_10 AC 89 ms
12,160 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 91 ms
12,160 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def win(te)
  case te
  when "G" then "P"
  when "C" then "G"
  when "P" then "C"
  end
end


tes = %w[G C P]
limits = [tes, gets.split(" ").map(&:to_i)].
  transpose.reduce({}){|h, (k,v)| h[k]=v; h}


sum = 0
gets.chomp.chars.each do |aite|
  me = win(aite)
  case
  when limits[me] > 0
    sum += 3
    limits[me] -= 1
  when limits[aite] > 0
    sum += 1
    limits[aite] -= 1
  else
    limits[(tes - [me, aite]).first] -= 1
  end
end

p sum
0