結果
| 問題 |
No.602 隠されていたゲーム2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-12-02 02:25:59 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 558 bytes |
| コンパイル時間 | 538 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 24,192 KB |
| 最終ジャッジ日時 | 2024-11-28 02:27:00 |
| 合計ジャッジ時間 | 4,157 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 WA * 5 |
コンパイルメッセージ
Main.rb:13: warning: ambiguous first argument; put parentheses or a space even after `-' operator Main.rb:21: warning: ambiguous first argument; put parentheses or a space even after `-' operator Main.rb:33: 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
ds = gets.chomp.split.map(&:to_i).sort.reverse
x, y = gets.chomp.split.map(&:to_i)
r = x.abs + y.abs
if ds.any? {|d| d == r}
p 1
elsif r.even?
d_max = ds[0]
if r <= d_max + d_max
p 2
else
p -1
end
else
es = ds.select(&:even?).sort.reverse
os = ds.select(&:odd?).sort.reverse
if es.size.zero? or os.size.zero?
p -1
exit
end
e_max = es[0]
o_max = os[0]
if es.any? {|d| d - o_max <= r and r <= d + o_max}
p 2
elsif os.any? {|d| d - e_max <= r and r <= d + e_max}
p 2
else
p -1
end
end