10776 | 2024-04-12 00:39:53 | 42 | Telefonközpont | python3 | Time limit exceeded 40/100 | 575ms | 17576 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 | 18ms | 11776 KiB | ||||
2 | Accepted | 19ms | 11944 KiB | ||||
subtask2 | 20/20 | ||||||
3 | Accepted | 20ms | 12104 KiB | ||||
4 | Accepted | 20ms | 12308 KiB | ||||
5 | Accepted | 20ms | 12672 KiB | ||||
6 | Accepted | 20ms | 12792 KiB | ||||
7 | Accepted | 19ms | 12696 KiB | ||||
8 | Accepted | 20ms | 13008 KiB | ||||
9 | Accepted | 19ms | 12924 KiB | ||||
subtask3 | 20/20 | ||||||
10 | Accepted | 20ms | 12104 KiB | ||||
11 | Accepted | 20ms | 12308 KiB | ||||
12 | Accepted | 20ms | 12672 KiB | ||||
13 | Accepted | 20ms | 12792 KiB | ||||
14 | Accepted | 19ms | 12696 KiB | ||||
15 | Accepted | 20ms | 13008 KiB | ||||
16 | Accepted | 19ms | 12924 KiB | ||||
17 | Accepted | 57ms | 14004 KiB | ||||
18 | Accepted | 59ms | 14216 KiB | ||||
19 | Accepted | 52ms | 14292 KiB | ||||
20 | Accepted | 52ms | 14304 KiB | ||||
21 | Accepted | 52ms | 14872 KiB | ||||
22 | Accepted | 52ms | 14608 KiB | ||||
23 | Accepted | 54ms | 14728 KiB | ||||
subtask4 | 0/60 | ||||||
24 | Accepted | 20ms | 12104 KiB | ||||
25 | Accepted | 20ms | 12308 KiB | ||||
26 | Accepted | 20ms | 12672 KiB | ||||
27 | Accepted | 20ms | 12792 KiB | ||||
28 | Accepted | 19ms | 12696 KiB | ||||
29 | Accepted | 20ms | 13008 KiB | ||||
30 | Accepted | 19ms | 12924 KiB | ||||
31 | Accepted | 57ms | 14004 KiB | ||||
32 | Accepted | 59ms | 14216 KiB | ||||
33 | Accepted | 52ms | 14292 KiB | ||||
34 | Accepted | 52ms | 14304 KiB | ||||
35 | Accepted | 52ms | 14872 KiB | ||||
36 | Accepted | 52ms | 14608 KiB | ||||
37 | Accepted | 54ms | 14728 KiB | ||||
38 | Time limit exceeded | 575ms | 17388 KiB | ||||
39 | Time limit exceeded | 556ms | 17420 KiB | ||||
40 | Time limit exceeded | 560ms | 17576 KiB | ||||
41 | Time limit exceeded | 560ms | 17420 KiB | ||||
42 | Time limit exceeded | 524ms | 17500 KiB | ||||
43 | Time limit exceeded | 550ms | 17444 KiB | ||||
44 | Time limit exceeded | 558ms | 17460 KiB |