Submission #1798289


Source Code Expand

__precompile__()

N, Z, W = parse.(split(readline(STDIN)))
a = parse.(split(readline(STDIN)))
unshift!(a, W)
N += 1

dpx, dpy = fill(-1, N), fill(-1, N)

function f(isx, pos)
    if isx
        if dpx[pos] < 0
            dpx[pos] = max(abs(a[pos] - a[N]), pos < N-1 ? maximum([f(false, p) for p in pos+1:N-1]) : typemin(Int64))
        end
        return dpx[pos]
    else
        if dpy[pos] < 0
            dpy[pos] = min(abs(a[pos] - a[N]), pos < N-1 ? minimum([f(true, p) for p in pos+1:N-1]) : typemax(Int64))
        end
        return dpy[pos]
    end
end

ans = f(true, 1)
println(ans)

Submission Info

Submission Time
Task D - ABS
User kitayuta
Language Julia (0.5.0)
Score 500
Code Size 618 Byte
Status AC
Exec Time 1484 ms
Memory 161220 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 4
AC × 28
Set Name Test Cases
Sample example_0, example_1, example_2, example_3
All example_0, example_1, example_2, example_3, one_0, one_1, one_2, one_3, one_4, one_5, one_6, one_7, rand_0, rand_1, rand_10, rand_11, rand_12, rand_13, rand_14, rand_15, rand_2, rand_3, rand_4, rand_5, rand_6, rand_7, rand_8, rand_9
Case Name Status Exec Time Memory
example_0 AC 656 ms 120976 KB
example_1 AC 659 ms 122148 KB
example_2 AC 655 ms 118404 KB
example_3 AC 571 ms 117924 KB
one_0 AC 576 ms 119688 KB
one_1 AC 581 ms 119648 KB
one_2 AC 581 ms 118068 KB
one_3 AC 574 ms 117376 KB
one_4 AC 573 ms 118572 KB
one_5 AC 577 ms 117840 KB
one_6 AC 573 ms 117880 KB
one_7 AC 577 ms 118580 KB
rand_0 AC 1435 ms 159860 KB
rand_1 AC 732 ms 145944 KB
rand_10 AC 1484 ms 159640 KB
rand_11 AC 838 ms 155576 KB
rand_12 AC 1425 ms 160544 KB
rand_13 AC 1267 ms 158680 KB
rand_14 AC 1474 ms 160212 KB
rand_15 AC 670 ms 123312 KB
rand_2 AC 1471 ms 159276 KB
rand_3 AC 1268 ms 158528 KB
rand_4 AC 1436 ms 158844 KB
rand_5 AC 1018 ms 156548 KB
rand_6 AC 1433 ms 158876 KB
rand_7 AC 1124 ms 158600 KB
rand_8 AC 1407 ms 161220 KB
rand_9 AC 1324 ms 159808 KB