#P1413. 坚果保龄球

坚果保龄球

Description

In the game PVZ, there is a mode called Wall-nut Bowling. Zombies appear from the right side of the map and walk left, and the player needs to roll wall-nuts from the left side to crush them.

We can model the map as a board with 66 rows and 6060 columns. A zombie, at the instant it appears, stands at column 6060 of its row, and then moves one step to the left every second. The player may place a wall-nut at column 11 of any row at any time; the wall-nut instantly rolls through that row and crushes all zombies currently on that row. If a zombie reaches column 11 and is not eliminated, and then moves further left, your brain will be eaten by the zombie.

Now there are nn zombies. You are given each zombie’s appearance time and row (multiple zombies may appear at the same position simultaneously). What is the minimum number of wall-nuts required to eliminate all zombies?

Input Format

The first line contains a positive integer nn, the number of zombies.

Each of the following nn lines contains two positive integers PP and tt, denoting the row index of the zombie and the time when the zombie appears.

Output Format

Output a single integer, the minimum number of wall-nuts required.

10
1 1
1 61
2 1
2 60
3 1
3 2
3 3
3 4
4 1
4 99999
6

Hint

Constraints

For all testdata, n2000n \le 2000, t100000t \le 100000, 1P61 \le P \le 6.

Source

Adapted from kkksc03.

Translated by ChatGPT 5