結果

問題 No.161 制限ジャンケン
ユーザー finefine
提出日時 2016-01-14 00:45:02
言語 Ruby
(3.3.0)
結果
AC  
実行時間 84 ms / 5,000 ms
コード長 414 bytes
コンパイル時間 413 ms
コンパイル使用メモリ 11,100 KB
実行使用メモリ 15,296 KB
最終ジャッジ日時 2023-08-20 04:45:23
合計ジャッジ時間 3,595 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,176 KB
testcase_01 AC 81 ms
15,296 KB
testcase_02 AC 81 ms
15,092 KB
testcase_03 AC 82 ms
15,148 KB
testcase_04 AC 82 ms
15,012 KB
testcase_05 AC 83 ms
15,040 KB
testcase_06 AC 82 ms
15,148 KB
testcase_07 AC 82 ms
15,056 KB
testcase_08 AC 84 ms
15,040 KB
testcase_09 AC 81 ms
15,244 KB
testcase_10 AC 81 ms
15,040 KB
testcase_11 AC 81 ms
15,092 KB
testcase_12 AC 82 ms
15,148 KB
testcase_13 AC 82 ms
15,016 KB
testcase_14 AC 82 ms
15,272 KB
testcase_15 AC 82 ms
15,124 KB
testcase_16 AC 80 ms
15,176 KB
testcase_17 AC 80 ms
15,128 KB
testcase_18 AC 80 ms
15,084 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

yuki = gets.split.map(&:to_i)
s = gets.chomp.split('')
enemy = Hash.new(0)
s.each{|char|
    enemy[char] += 1
    }
enemy = [enemy['G'],enemy['C'],enemy['P']]
win = [[enemy[1],yuki[0]],[enemy[2],yuki[1]],[enemy[0],yuki[2]]].map(&:min)
3.times{|i|
    yuki[i] -= win[i]
    enemy[i] -= win[(i + 2) % 3]
    }
draw = []
3.times{|i|
    draw.push([yuki[i],enemy[i]].min)
    }
p win.inject(&:+) * 3 + draw.inject(&:+)
0