luogu#P9726. [EC Final 2022] Magic
[EC Final 2022] Magic
题目描述
Warning: Unusual memory limit!
You are given a sequence . Initially, all numbers are zero.
There are operations. The -th operation is represented by two integers (), which assigns to . It is guaranteed that all the integers, , are distinct.
You need to perform each operation exactly once, in arbitrary order.
You want to maximize the number of such that after all operations. Output the maximum number.
输入格式
The first line contains an integer ().
The -th line of the next lines contains a pair of integers (). It is guaranteed that all the integers, , are distinct.
输出格式
Output one integer representing the answer in one line.
题目大意
- 你有一个序列 ,初始全为 。
- 给定 个区间赋值操作,第 个操作 表示把区间 全部赋值为 ,保证所有 互不相同。
- 你可以指定一个执行操作的顺序,最大化 ,输出这个最大值。
- ,注意空间限制。
5
2 3
6 7
1 9
5 10
4 8
9