Submission #856837


Source Code Expand

Copy
import bisect

n=int(raw_input())
x=map(int,raw_input().split())
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 0
Code Size 757 Byte
Status TLE
Exec Time 3161 ms
Memory 29024 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 0 / 200 0 / 500
Status
AC × 1
AC × 3
RE × 11
AC × 3
TLE × 8
RE × 16
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 RE 58 ms 8944 KB
subtask1_02.txt AC 56 ms 8944 KB
subtask1_03.txt RE 184 ms 16624 KB
subtask1_04.txt RE 366 ms 21532 KB
subtask1_05.txt RE 69 ms 9456 KB
subtask1_06.txt RE 239 ms 19484 KB
subtask1_07.txt RE 59 ms 8944 KB
subtask1_08.txt RE 62 ms 9200 KB
subtask1_09.txt RE 311 ms 22428 KB
subtask1_10.txt RE 160 ms 19564 KB
subtask1_11.txt RE 97 ms 11120 KB
subtask1_12.txt RE 454 ms 22684 KB
subtask1_13.txt AC 474 ms 22556 KB
subtask2_01.txt TLE 3157 ms 29024 KB
subtask2_02.txt TLE 3156 ms 25040 KB
subtask2_03.txt RE 527 ms 24992 KB
subtask2_04.txt RE 92 ms 17904 KB
subtask2_05.txt TLE 3161 ms 27372 KB
subtask2_06.txt RE 117 ms 23792 KB
subtask2_07.txt TLE 3161 ms 26576 KB
subtask2_08.txt TLE 3161 ms 26648 KB
subtask2_09.txt TLE 3157 ms 26696 KB
subtask2_10.txt TLE 3157 ms 26160 KB
subtask2_11.txt TLE 3157 ms 25592 KB
subtask2_12.txt RE 322 ms 23312 KB
subtask2_13.txt RE 105 ms 22512 KB