結果

問題 No.602 隠されていたゲーム2
ユーザー maimai
提出日時 2017-12-03 00:16:03
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 664 bytes
コンパイル時間 146 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 19,328 KB
最終ジャッジ日時 2024-05-06 02:02:16
合計ジャッジ時間 3,198 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
12,160 KB
testcase_01 AC 76 ms
12,160 KB
testcase_02 AC 74 ms
12,288 KB
testcase_03 AC 77 ms
12,288 KB
testcase_04 AC 76 ms
12,160 KB
testcase_05 AC 80 ms
12,160 KB
testcase_06 AC 78 ms
12,416 KB
testcase_07 AC 75 ms
12,160 KB
testcase_08 AC 78 ms
12,288 KB
testcase_09 AC 75 ms
12,288 KB
testcase_10 AC 78 ms
12,160 KB
testcase_11 AC 75 ms
12,160 KB
testcase_12 AC 76 ms
12,288 KB
testcase_13 AC 75 ms
12,160 KB
testcase_14 AC 77 ms
12,160 KB
testcase_15 AC 79 ms
12,288 KB
testcase_16 AC 88 ms
12,800 KB
testcase_17 WA -
testcase_18 AC 108 ms
17,664 KB
testcase_19 WA -
testcase_20 AC 126 ms
18,688 KB
testcase_21 AC 139 ms
18,816 KB
testcase_22 AC 112 ms
19,328 KB
testcase_23 AC 123 ms
19,328 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:42: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

gets
d = gets.split.map(&:to_i)
x1,y1 = gets.split.map(&:to_i)
z = [x1+y1,x1-y1].map(&:abs).max

if z==0
    p 0;exit
end

if d.include?(z)
    p 1;exit
end


if z.even?
    dmax = d.max
    
    if z < dmax
        p 2;exit
    end
    
    u = (z+dmax-1)/dmax
    p 2 < u ? -1 : u
else
    
    dmaxeven = nil
    dmaxodd = nil
    
    d.each do |e|
        if e.even?
            dmaxeven = e
        else
            dmaxodd = e
        end
        next if dmaxeven.nil? || dmaxodd.nil?
        l = [dmaxeven,dmaxodd].max - [dmaxeven,dmaxodd].min
        h = dmaxeven + dmaxodd
        if l <= z && z <= h
            p 2;exit
        end
    end
    p -1
end
0