#54743: tip:Python 中的bisect超好用的()


qiqiloveke@gmail.com (弭兒)


left right left right...

記得排序

#54869: Re: tip:Python 中的bisect超好用的()


sc.lin.03221102@gmail.com (你好哇)


left right left right...

記得排序

然後呢?我全部memory error,求解

n=[int(x) for x in input().split()]
d=[int(x) for x in input().split()]
show_start=[]
show_end=[]
showing=0
ans=0
for i in range(n[1]):
    show=[int(x) for x in input().split()]
    show_start.append(show[0])
    show_end.append(show[1]+1)
print(n)
show_start.sort()
show_end.sort()
time=[0 for i in range(max(show_end))]
for i in range(max(show_end)):
    if i+1 in show_start:
        showing+=show_start.count(i+1)
    if i+1 in show_end:
        showing-=show_end.count(i+1)
    time[i]+=showing
for i in range(n[0]):
    ans+=time[d[i]-1]
print(ans)