Submission #1798281


Source Code Expand

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 598 Byte
Status AC
Exec Time 1427 ms
Memory 184884 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 1166 ms 184884 KB
example_1 AC 657 ms 120472 KB
example_2 AC 657 ms 120880 KB
example_3 AC 567 ms 119284 KB
one_0 AC 575 ms 115928 KB
one_1 AC 575 ms 116128 KB
one_2 AC 571 ms 119296 KB
one_3 AC 575 ms 120416 KB
one_4 AC 568 ms 119244 KB
one_5 AC 581 ms 118324 KB
one_6 AC 572 ms 117212 KB
one_7 AC 577 ms 117800 KB
rand_0 AC 1364 ms 159464 KB
rand_1 AC 731 ms 144664 KB
rand_10 AC 1427 ms 159640 KB
rand_11 AC 830 ms 155568 KB
rand_12 AC 1374 ms 159108 KB
rand_13 AC 1245 ms 159792 KB
rand_14 AC 1371 ms 159360 KB
rand_15 AC 663 ms 123056 KB
rand_2 AC 1380 ms 159700 KB
rand_3 AC 1303 ms 159688 KB
rand_4 AC 1369 ms 161612 KB
rand_5 AC 1018 ms 158732 KB
rand_6 AC 1361 ms 159652 KB
rand_7 AC 1095 ms 158184 KB
rand_8 AC 1377 ms 159488 KB
rand_9 AC 1254 ms 159188 KB