結果
| 問題 |
No.161 制限ジャンケン
|
| コンテスト | |
| ユーザー |
d_nishiyama85
|
| 提出日時 | 2016-06-13 22:54:08 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 699 bytes |
| コンパイル時間 | 189 ms |
| コンパイル使用メモリ | 7,680 KB |
| 実行使用メモリ | 12,416 KB |
| 最終ジャッジ日時 | 2024-10-09 13:30:15 |
| 合計ジャッジ時間 | 2,632 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 WA * 9 |
コンパイルメッセージ
Syntax OK
ソースコード
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
d_nishiyama85