Submission #1794422


Source Code Expand

# coding: utf-8

line = input().rstrip().split()
N = int(line[0])
X = int(line[1])
Y = int(line[2])

list = input().rstrip().split()

now = -1

def turn_x(tmp):
    global X
    store = tmp + 1
    max = abs(Y - int(list[store]))
    if store == N-1:
        X = int(list[store])
        return store
    else:
        for work in range(tmp+2,N):
            if max < abs(Y - int(list[work])):
                store = work
                max = abs(Y - int(list[work]))
                X = int(list[work])
        return store
    
def turn_y(tmp):
    global Y
    store = tmp + 1
    min = abs(X - int(list[store]))
    if store == N-1:
        Y = int(list[store])
        return store
    else:
        for work in range(tmp+2,N):
            if min > abs(X - int(list[work])):
                store = work
                min = abs(X - int(list[work]))
                Y = int(list[work])
        return store

while now < N-1:
    now = turn_x(now)
    if now ==N-1:
        break
    else:
        now = turn_y(now)

print(abs(X-Y))

Submission Info

Submission Time
Task D - ABS
User kj1321
Language Python (3.4.3)
Score 0
Code Size 1087 Byte
Status WA
Exec Time 19 ms
Memory 3188 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 4
AC × 18
WA × 10
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 17 ms 3064 KB
example_1 AC 17 ms 3064 KB
example_2 AC 17 ms 3064 KB
example_3 AC 17 ms 3064 KB
one_0 AC 17 ms 3064 KB
one_1 AC 17 ms 3064 KB
one_2 AC 17 ms 3064 KB
one_3 AC 17 ms 3064 KB
one_4 AC 17 ms 3064 KB
one_5 AC 17 ms 3064 KB
one_6 AC 17 ms 3064 KB
one_7 AC 17 ms 3064 KB
rand_0 WA 18 ms 3188 KB
rand_1 AC 18 ms 3064 KB
rand_10 WA 18 ms 3188 KB
rand_11 WA 18 ms 3064 KB
rand_12 WA 18 ms 3188 KB
rand_13 AC 18 ms 3188 KB
rand_14 WA 19 ms 3188 KB
rand_15 WA 17 ms 3064 KB
rand_2 WA 18 ms 3188 KB
rand_3 WA 18 ms 3188 KB
rand_4 AC 18 ms 3188 KB
rand_5 AC 18 ms 3064 KB
rand_6 AC 18 ms 3188 KB
rand_7 WA 18 ms 3064 KB
rand_8 AC 19 ms 3188 KB
rand_9 WA 18 ms 3188 KB