-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrestaurant_customers.py
More file actions
59 lines (45 loc) · 1.02 KB
/
restaurant_customers.py
File metadata and controls
59 lines (45 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# =======================
# Python CP Template
# (bits/stdc++.h equivalent)
# =======================
import sys
import math
import threading
# Fast I/O
input = sys.stdin.readline
# Common imports
from collections import defaultdict, deque, Counter
from itertools import combinations, permutations, product, accumulate
from functools import lru_cache, reduce
import heapq
import bisect
# Constants
INF = float('inf')
MOD = 10**9 + 7
# =======================
# Main Logic
# =======================
def solve():
data = sys.stdin.buffer.read().split()
n = int(data[0])
visits = []
idx = 1
for _ in range(n):
u = int(data[idx])
v = int(data[idx + 1])
idx += 2
visits.append((u, 1))
visits.append((v, -1))
visits.sort()
cur = 0
ans = 0
for _, d in visits:
cur += d
if cur > ans:
ans = cur
sys.stdout.write(str(ans))
# =======================
# Entry Point
# =======================
if __name__ == "__main__":
solve()