#P2652. 同花顺
同花顺
Description
Now I have playing cards, but they may not form a straight flush. I want to know the minimum number of cards I need to replace so that all cards form a straight flush.
Input Format
The first line contains an integer , indicating the number of playing cards.
Then lines follow, each containing two integers and . Here, denotes the suit of the -th card, and denotes the rank of the -th card.
Output Format
Output a single integer on one line, indicating the minimum number of cards that need to be replaced to achieve the goal.
5
1 1
1 2
1 3
1 4
1 5
0
5
1 9
1 10
2 11
2 12
2 13
2
Hint
- For of the testdata, .
- For of the testdata, , , .
- For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号