CF1389F.Bicolored Segments
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given n segments [l1,r1],[l2,r2],…,[ln,rn] . Each segment has one of two colors: the i -th segment's color is ti .
Let's call a pair of segments i and j bad if the following two conditions are met:
- ti=tj ;
- the segments [li,ri] and [lj,rj] intersect, embed or touch, i. e. there exists an integer x such that x∈[li,ri] and x∈[lj,rj] .
Calculate the maximum number of segments that can be selected from the given ones, so that there is no bad pair among the selected ones.
输入格式
The first line contains a single integer n ( 1≤n≤2⋅105 ) — number of segments.
The next n lines contains three integers li,ri,ti ( 1≤li≤ri≤109;ti∈{1,2} ) — description of the i -th segment.
输出格式
Print the maximum number of segments that can be selected, so that there is no bad pair among the selected segments.
输入输出样例
输入#1
3 1 3 1 4 6 2 2 5 1
输出#1
2
输入#2
5 5 8 1 1 3 2 3 4 2 6 6 1 2 10 2
输出#2
4
输入#3
7 19 20 1 13 15 2 6 11 2 4 10 1 14 17 1 13 13 2 5 9 1
输出#3
5