結果
| 問題 |
No.602 隠されていたゲーム2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-12-02 18:41:28 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 511 bytes |
| コンパイル時間 | 57 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 20,224 KB |
| 最終ジャッジ日時 | 2024-11-28 03:39:54 |
| 合計ジャッジ時間 | 3,493 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 WA * 4 |
コンパイルメッセージ
Main.rb:14: warning: ambiguous first argument; put parentheses or a space even after `-' operator Main.rb:20: warning: ambiguous first argument; put parentheses or a space even after `-' operator Main.rb:24: warning: ambiguous first argument; put parentheses or a space even after `-' operator Main.rb:1: warning: assigned but unused variable - n Syntax OK
ソースコード
n = gets.to_i
d = gets.split.map(&:to_i)
x, y = gets.split.map(&:to_i)
sum = x.abs + y.abs
if x == 0 && y == 0
p 0
elsif d.include?(sum)
p 1
else
if sum % 2 == 0
if d.max * 2 >= sum
p 2
else
p -1
end
else
hoge = d.select{|x| x % 2 == 0}
foo = d.select{|x| x % 2 == 1}
if hoge.empty? || foo.empty?
p -1
elsif hoge.max + foo.max >= sum
p 2
else
p -1
end
end
end