10777 | 2024-04-12 00:40:26 | 42 | Telefonközpont | pypy3 | Elfogadva 100/100 | 453ms | 120800 KiB |
from sys import stdin
input=stdin.readline
class SegmentTree:
def __init__(self):
self.tree = None
def buildTree(self,List):
n = len(List)
self.tree = [0 for i in range(2*n)]
for i in range(n):
self.tree[i+n] = List[i]
for i in range(n-1,0,-1):
self.tree[i] = max(self.tree[i<<1],self.tree[i<<1 | 1])
def maxInRange(self, left, right):
n = len(self.tree)//2
result = 0
left += n
right += n
while left<right:
if left&1:
result = max(result, self.tree[left])
left += 1
if right&1:
right -= 1
result = max(result, self.tree[right])
left >>= 1
right >>= 1
return result
def main():
M,N,Q = [int(x) for x in input().split()]
start=[0]*(M+1)
end=[0]*(M+1)
for i in range(N):
A,B = [int(x) for x in input().split()]
start[A]+=1
end[B]+=1
darab=[0]*(M+1)
cur=0
for i in range(1,M+1):
cur+=start[i]
darab[i]=cur
cur-=end[i]
segmentTree = SegmentTree()
segmentTree.buildTree(darab)
for i in range(Q):
A,B = [int(x) for x in input().split()]
print(segmentTree.maxInRange(A,B+1))
main()
Részfeladat | Összpont | Teszt | Verdikt | Idő | Memória | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Elfogadva | 41ms | 77232 KiB | ||||
2 | Elfogadva | 52ms | 80540 KiB | ||||
subtask2 | 20/20 | ||||||
3 | Elfogadva | 57ms | 86216 KiB | ||||
4 | Elfogadva | 54ms | 86952 KiB | ||||
5 | Elfogadva | 61ms | 86616 KiB | ||||
6 | Elfogadva | 61ms | 87060 KiB | ||||
7 | Elfogadva | 61ms | 87808 KiB | ||||
8 | Elfogadva | 56ms | 87672 KiB | ||||
9 | Elfogadva | 52ms | 87640 KiB | ||||
subtask3 | 20/20 | ||||||
10 | Elfogadva | 57ms | 86216 KiB | ||||
11 | Elfogadva | 54ms | 86952 KiB | ||||
12 | Elfogadva | 61ms | 86616 KiB | ||||
13 | Elfogadva | 61ms | 87060 KiB | ||||
14 | Elfogadva | 61ms | 87808 KiB | ||||
15 | Elfogadva | 56ms | 87672 KiB | ||||
16 | Elfogadva | 52ms | 87640 KiB | ||||
17 | Elfogadva | 172ms | 96380 KiB | ||||
18 | Elfogadva | 171ms | 97628 KiB | ||||
19 | Elfogadva | 163ms | 96516 KiB | ||||
20 | Elfogadva | 168ms | 96688 KiB | ||||
21 | Elfogadva | 167ms | 97220 KiB | ||||
22 | Elfogadva | 165ms | 97440 KiB | ||||
23 | Elfogadva | 166ms | 95480 KiB | ||||
subtask4 | 60/60 | ||||||
24 | Elfogadva | 57ms | 86216 KiB | ||||
25 | Elfogadva | 54ms | 86952 KiB | ||||
26 | Elfogadva | 61ms | 86616 KiB | ||||
27 | Elfogadva | 61ms | 87060 KiB | ||||
28 | Elfogadva | 61ms | 87808 KiB | ||||
29 | Elfogadva | 56ms | 87672 KiB | ||||
30 | Elfogadva | 52ms | 87640 KiB | ||||
31 | Elfogadva | 172ms | 96380 KiB | ||||
32 | Elfogadva | 171ms | 97628 KiB | ||||
33 | Elfogadva | 163ms | 96516 KiB | ||||
34 | Elfogadva | 168ms | 96688 KiB | ||||
35 | Elfogadva | 167ms | 97220 KiB | ||||
36 | Elfogadva | 165ms | 97440 KiB | ||||
37 | Elfogadva | 166ms | 95480 KiB | ||||
38 | Elfogadva | 437ms | 120420 KiB | ||||
39 | Elfogadva | 453ms | 119612 KiB | ||||
40 | Elfogadva | 409ms | 119588 KiB | ||||
41 | Elfogadva | 432ms | 119296 KiB | ||||
42 | Elfogadva | 409ms | 119640 KiB | ||||
43 | Elfogadva | 426ms | 120676 KiB | ||||
44 | Elfogadva | 423ms | 120800 KiB |