Submission #23437985


Source Code Expand

n,q=map(int,input().split())
a=list(map(int,input().split()))
l=[]
r=1
for i in a:
    if r==i:
        r+=1
        continue
    l.append((r,i))
    r=i+1
l.append((r,float("inf")))
#print(l)
e=[(0,l[0][0])]
for i in range(len(l)-1):
    e.append((e[i][0]+l[i][1]-l[i][0],l[i+1][0]))
#print(e)
for i in range(q):
    k=int(input())
    ok,ng=0,len(l)
    while ok<ng-1:
        half=(ok+ng)//2
        if e[half][0]<k:
            ok=half
        else:
            ng=half
    print(e[ok][1]-e[ok][0]+k-1)

Submission Info

Submission Time
Task D - Kth Excluded
User akimasa_l
Language Python (3.8.2)
Score 400
Code Size 531 Byte
Status AC
Exec Time 993 ms
Memory 36092 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 19
Set Name Test Cases
Sample example_00.txt, example_01.txt
All block_00.txt, block_01.txt, block_02.txt, block_03.txt, block_04.txt, example_00.txt, example_01.txt, killer_00.txt, killer_01.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt
Case Name Status Exec Time Memory
block_00.txt AC 513 ms 22316 KiB
block_01.txt AC 419 ms 17732 KiB
block_02.txt AC 301 ms 17132 KiB
block_03.txt AC 290 ms 11772 KiB
block_04.txt AC 108 ms 9628 KiB
example_00.txt AC 24 ms 9048 KiB
example_01.txt AC 22 ms 9172 KiB
killer_00.txt AC 973 ms 34652 KiB
killer_01.txt AC 411 ms 20304 KiB
random_00.txt AC 993 ms 36092 KiB
random_01.txt AC 104 ms 9424 KiB
random_02.txt AC 689 ms 33680 KiB
random_03.txt AC 794 ms 27792 KiB
random_04.txt AC 219 ms 34156 KiB
random_05.txt AC 863 ms 28380 KiB
random_06.txt AC 198 ms 10436 KiB
random_07.txt AC 311 ms 24064 KiB
random_08.txt AC 739 ms 33336 KiB
random_09.txt AC 936 ms 29384 KiB