#P15433. [蓝桥杯 2025 国 Python B] 灯塔
[蓝桥杯 2025 国 Python B] 灯塔
Problem Description
On a coastline, there are lighthouses in a row, numbered from to from left to right. You need to light up some of them to guide ships. You are given a lighting sequence , where the -th operation means trying to light the lighthouse numbered . However, to save energy, if lighthouse or lighthouse has already been lit, then lighthouse cannot be lit and this operation will be skipped. Of course, the same lighthouse will be lit at most once.
You may choose a subsequence from the given lighting sequence (keeping the relative order of operations), and execute the lighting operations one by one in the order of the subsequence. What is the maximum number of lighthouses that can be successfully lit?
Input Format
The first line contains two positive integers , separated by a space.
The second line contains positive integers , with a space between adjacent integers.
Output Format
Output one line containing one integer, which is the answer.
10 9
1 3 2 5 2 10 9 6 5
4
Hint
Sample Explanation
One possible plan: keep the subsequence , which can light up lighthouses.
Testdata Scale and Constraints
For of the test cases, .
For all test cases, , and .
Translated by ChatGPT 5