結果
| 問題 | No.602 隠されていたゲーム2 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2017-12-03 05:27:56 | 
| 言語 | Ruby (3.4.1) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 560 bytes | 
| コンパイル時間 | 143 ms | 
| コンパイル使用メモリ | 7,424 KB | 
| 実行使用メモリ | 25,216 KB | 
| 最終ジャッジ日時 | 2024-11-28 08:32:07 | 
| 合計ジャッジ時間 | 4,370 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 WA * 1 | 
| other | AC * 6 WA * 15 | 
コンパイルメッセージ
Main.rb:20: 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:39: 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)
x, y = gets.chomp.split.map(&:to_i)
r = x.abs + y.abs
if r.zero?
  p 0
elsif ds.any? {|d| d == r}
  p 1
elsif r.even?
  d_max = ds.max
  if r <= d_max + d_max
    p 2
  else
    p -1
  end
else
  es = ds.select(&:even?)
  os = ds.select(&:odd?)
  e_max = es.max
  o_max = os.max
  p es
  p os
  if e_max == nil or o_max == nil
    p -1
  elsif es.any? {|d| (d - o_max).abs <= r and r <= d + o_max}
    p 2
  elsif os.any? {|d| (d - e_max).abs <= r and r <= d + e_max}
    p 2
  else
    p -1
  end
end
            
            
            
        