-
Notifications
You must be signed in to change notification settings - Fork 185
/
Copy pathd.py
executable file
·46 lines (46 loc) · 1004 Bytes
/
d.py
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
#!/usr/bin/env python2
# https://abc080.contest.atcoder.jp/tasks/abc080_d
[n, c] = map(int, raw_input().split())
cs = [None] * c
for i in range(c):
cs[i] = list()
for i in range(n):
[s, t, ci] = map(int, raw_input().split())
cs[ci - 1].append((s, t))
starts = []
ends = []
for i in range(c):
if len(cs[i]) == 0: continue
cs[i].sort()
j = 0
k = 0
while j + k < len(cs[i]) - 1:
a = cs[i][j+k][1]
b = cs[i][j+k+1][0]
if a == b:
k += 1
else:
start = cs[i][j][0]
end = cs[i][j+k][1]
starts.append(start)
ends.append(end)
j += k + 1
k = 0
start = cs[i][j][0]
end = cs[i][j+k][1]
starts.append(start)
ends.append(end)
starts.sort()
ends.sort()
i = 0
j = 0
d = 0
while i < len(starts) and j < len(ends):
if starts[i] < ends[j]:
i += 1
elif starts[i] == ends[j]:
i += 1
else:
j += 1
d = max(d, i - j)
print d