#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