#P2519. [HAOI2011] problem a

    ID: 1534 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>动态规划,dp贪心递推2011河南各省省选

[HAOI2011] problem a

Description

An exam has nn participants, and multiple people may have the same score. The ii-th person says: "There are aia_i people who scored higher than me, and bib_i people who scored lower than me."

Find the minimum number of people who did not tell the truth.

Input Format

The first line contains an integer nn, the number of participants.

Lines 22 to (n+1)(n + 1) each contain two space-separated integers. On the (i+1)(i + 1)-th line, the two integers represent the number of people scoring higher than the ii-th person aia_i and the number of people scoring lower than the ii-th person bib_i.

Output Format

Output a single integer, the minimum number of people who did not tell the truth.

3
2 0
0 2
2 2
1

Hint

For 100%100\% of the testdata, it is guaranteed that 1n1051 \leq n \leq 10^5, 0ai,bin0 \leq a_i, b_i \leq n.

Translated by ChatGPT 5