Submission #855491


Source Code Expand

Copy
from bisect import bisect_right

N = int(input())
X = list(map(int, input().split()))
L = int(input())
Q = int(input())

def calc(i, a, b):
    now = a
    res = 0
    while True:
        # print("dbg", now, X[now])
        # print(bisect_left(X, X[now] + L))
        # print(i, now)
        if now >= b:
            break
        now = bisect_right(X, X[now] + L) - 1
        res += 1
    return res


for q in range(Q):
    a, b = map(int, input().split())
    if a > b:
        a, b = b, a
    a -= 1
    b -= 1
    print(calc(q, a, b))

Submission Info

Submission Time
Task E - Tak and Hotels
User poyodr
Language Python (3.4.3)
Score 200
Code Size 568 Byte
Status TLE
Exec Time 3158 ms
Memory 15216 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 200 / 200 0 / 500
Status
AC × 1
AC × 14
AC × 17
TLE × 10
Set Name Test Cases
Sample example_01.txt
Subtask1 example_01.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt
All example_01.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask2_13.txt
Case Name Status Exec Time Memory
example_01.txt AC 38 ms 3188 KB
subtask1_01.txt AC 40 ms 3064 KB
subtask1_02.txt AC 38 ms 3064 KB
subtask1_03.txt AC 88 ms 3064 KB
subtask1_04.txt AC 326 ms 3188 KB
subtask1_05.txt AC 62 ms 3188 KB
subtask1_06.txt AC 114 ms 3064 KB
subtask1_07.txt AC 52 ms 3064 KB
subtask1_08.txt AC 58 ms 3188 KB
subtask1_09.txt AC 119 ms 3188 KB
subtask1_10.txt AC 235 ms 3188 KB
subtask1_11.txt AC 249 ms 3188 KB
subtask1_12.txt AC 242 ms 3188 KB
subtask1_13.txt AC 215 ms 3188 KB
subtask2_01.txt TLE 3158 ms 13940 KB
subtask2_02.txt TLE 3158 ms 14252 KB
subtask2_03.txt TLE 3154 ms 14252 KB
subtask2_04.txt AC 1457 ms 10360 KB
subtask2_05.txt TLE 3157 ms 10360 KB
subtask2_06.txt AC 2231 ms 14252 KB
subtask2_07.txt TLE 3158 ms 14252 KB
subtask2_08.txt TLE 3158 ms 14096 KB
subtask2_09.txt TLE 3154 ms 14760 KB
subtask2_10.txt TLE 3154 ms 14172 KB
subtask2_11.txt TLE 3154 ms 13440 KB
subtask2_12.txt TLE 3154 ms 14756 KB
subtask2_13.txt AC 2513 ms 15216 KB