結果

問題 No.451 575
ユーザー zazaboonzazaboon
提出日時 2016-12-24 17:30:13
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 650 bytes
コンパイル時間 213 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 25,984 KB
最終ジャッジ日時 2024-05-09 19:18:27
合計ジャッジ時間 6,800 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
12,288 KB
testcase_01 AC 73 ms
12,160 KB
testcase_02 AC 73 ms
12,032 KB
testcase_03 AC 70 ms
12,288 KB
testcase_04 AC 115 ms
12,160 KB
testcase_05 AC 75 ms
12,544 KB
testcase_06 AC 81 ms
13,184 KB
testcase_07 AC 175 ms
23,808 KB
testcase_08 AC 72 ms
12,416 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 73 ms
12,416 KB
testcase_15 AC 73 ms
12,160 KB
testcase_16 AC 83 ms
13,440 KB
testcase_17 AC 131 ms
24,192 KB
testcase_18 WA -
testcase_19 AC 115 ms
19,712 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 75 ms
12,288 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 74 ms
12,288 KB
testcase_27 AC 76 ms
12,160 KB
testcase_28 AC 73 ms
12,032 KB
testcase_29 AC 83 ms
12,928 KB
testcase_30 AC 145 ms
23,808 KB
testcase_31 AC 74 ms
12,160 KB
testcase_32 AC 88 ms
14,208 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:36: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

def judge(n,fl)
    puts n if(fl == 1)
    e = 1
    while(e <= $a[0])
        if(e%2 == 1)
            n = ($a[e] - n)
            return 1 if(n < 0)
        else
            n -= $a[e] 
            return 2 if(n < 0)
        end
    e += 1
    puts n if(fl == 1)
    end
    return 0
end
$a = `dd`.split("\n").map{|u|u.to_i}
$za = 10**18
right = $a[1..3].max
left = 0
r = 0
while (right - left > 1)
    mid = left + (right + left)/2
    if(judge(mid, 0) == 1)
        left = mid
    elsif(judge(mid, 0) == 2)
        right = mid
    else
        puts $a[0] + 1
        judge(mid,1)
        exit
    end
    r+=1
    break if(r > 100000)
end
puts -1
0