10777 | 2024-04-12 00:40:26 | 42 | Telefonközpont | pypy3 | Accepted 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()
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 41ms | 77232 KiB | ||||
2 | Accepted | 52ms | 80540 KiB | ||||
subtask2 | 20/20 | ||||||
3 | Accepted | 57ms | 86216 KiB | ||||
4 | Accepted | 54ms | 86952 KiB | ||||
5 | Accepted | 61ms | 86616 KiB | ||||
6 | Accepted | 61ms | 87060 KiB | ||||
7 | Accepted | 61ms | 87808 KiB | ||||
8 | Accepted | 56ms | 87672 KiB | ||||
9 | Accepted | 52ms | 87640 KiB | ||||
subtask3 | 20/20 | ||||||
10 | Accepted | 57ms | 86216 KiB | ||||
11 | Accepted | 54ms | 86952 KiB | ||||
12 | Accepted | 61ms | 86616 KiB | ||||
13 | Accepted | 61ms | 87060 KiB | ||||
14 | Accepted | 61ms | 87808 KiB | ||||
15 | Accepted | 56ms | 87672 KiB | ||||
16 | Accepted | 52ms | 87640 KiB | ||||
17 | Accepted | 172ms | 96380 KiB | ||||
18 | Accepted | 171ms | 97628 KiB | ||||
19 | Accepted | 163ms | 96516 KiB | ||||
20 | Accepted | 168ms | 96688 KiB | ||||
21 | Accepted | 167ms | 97220 KiB | ||||
22 | Accepted | 165ms | 97440 KiB | ||||
23 | Accepted | 166ms | 95480 KiB | ||||
subtask4 | 60/60 | ||||||
24 | Accepted | 57ms | 86216 KiB | ||||
25 | Accepted | 54ms | 86952 KiB | ||||
26 | Accepted | 61ms | 86616 KiB | ||||
27 | Accepted | 61ms | 87060 KiB | ||||
28 | Accepted | 61ms | 87808 KiB | ||||
29 | Accepted | 56ms | 87672 KiB | ||||
30 | Accepted | 52ms | 87640 KiB | ||||
31 | Accepted | 172ms | 96380 KiB | ||||
32 | Accepted | 171ms | 97628 KiB | ||||
33 | Accepted | 163ms | 96516 KiB | ||||
34 | Accepted | 168ms | 96688 KiB | ||||
35 | Accepted | 167ms | 97220 KiB | ||||
36 | Accepted | 165ms | 97440 KiB | ||||
37 | Accepted | 166ms | 95480 KiB | ||||
38 | Accepted | 437ms | 120420 KiB | ||||
39 | Accepted | 453ms | 119612 KiB | ||||
40 | Accepted | 409ms | 119588 KiB | ||||
41 | Accepted | 432ms | 119296 KiB | ||||
42 | Accepted | 409ms | 119640 KiB | ||||
43 | Accepted | 426ms | 120676 KiB | ||||
44 | Accepted | 423ms | 120800 KiB |