Submission #856938


Source Code Expand

Copy
import bisect

n=int(raw_input())
x=map(int,raw_input().split())+[float('inf')]
l=int(raw_input())
q=int(raw_input())
for i in xrange(q):
    a,b=map(int,raw_input().split())
    a-=1
    b-=1
    cnt=0
    if a<b:
        while a!=b:
            cnt+=1
            if x[a]+l==x[bisect.bisect_left(x,x[a]+l)]:
                a=bisect.bisect_left(x,x[a]+l)
            else:
                a=bisect.bisect_left(x,x[a]+l)-1
            if a>b:
                break
    else:
        while a!=b:
            cnt+=1
            if x[a]-l==x[bisect.bisect_left(x,x[a]-l)]:
                a=bisect.bisect_left(x,x[a]-l)
            else:
                a=bisect.bisect_left(x,x[a]-l)
            if a<b:
                break
    print(cnt)

Submission Info

Submission Time
Task E - Tak and Hotels
User yugamiakira
Language PyPy2 (5.6.0)
Score 200
Code Size 768 Byte
Status TLE
Exec Time 3161 ms
Memory 36648 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 60 ms 8944 KB
subtask1_01.txt AC 70 ms 9584 KB
subtask1_02.txt AC 57 ms 8944 KB
subtask1_03.txt AC 732 ms 26140 KB
subtask1_04.txt AC 621 ms 22556 KB
subtask1_05.txt AC 247 ms 20208 KB
subtask1_06.txt AC 314 ms 22940 KB
subtask1_07.txt AC 124 ms 10352 KB
subtask1_08.txt AC 155 ms 11376 KB
subtask1_09.txt AC 360 ms 22940 KB
subtask1_10.txt AC 511 ms 22428 KB
subtask1_11.txt AC 584 ms 22684 KB
subtask1_12.txt AC 524 ms 22812 KB
subtask1_13.txt AC 490 ms 22684 KB
subtask2_01.txt TLE 3157 ms 29920 KB
subtask2_02.txt TLE 3160 ms 25936 KB
subtask2_03.txt TLE 3157 ms 32592 KB
subtask2_04.txt AC 1021 ms 25836 KB
subtask2_05.txt TLE 3157 ms 28012 KB
subtask2_06.txt AC 1305 ms 28448 KB
subtask2_07.txt TLE 3157 ms 27472 KB
subtask2_08.txt TLE 3157 ms 27672 KB
subtask2_09.txt TLE 3157 ms 27592 KB
subtask2_10.txt TLE 3161 ms 27056 KB
subtask2_11.txt TLE 3157 ms 26616 KB
subtask2_12.txt TLE 3157 ms 26176 KB
subtask2_13.txt AC 1745 ms 36648 KB