#P3419. [POI 2005] SAM-Toy Cars
[POI 2005] SAM-Toy Cars
Description
Jasio is a three-year-old boy who loves to play with toy cars. He has toy cars stored on a shelf.
Jasio cannot reach the toy cars on the shelf, but he can reach the ones on the floor. Jasio’s mother helps by moving toy cars from the shelf to the floor.
The floor can hold at most toy cars.
When there are already toy cars on the floor, Jasio’s mother will first take one toy car from the floor back to the shelf, and then bring the toy car that Jasio wants.
Now Jasio wants to play with toy cars in order. Determine the minimum number of times his mother needs to take a toy car down. (Only count taking down from the shelf; do not count putting back.)
Input Format
The first line contains three integers , and .
The next lines each contain exactly one integer , indicating the ID of the toy car Jasio wants.
Output Format
Output a single integer, the minimum number of times Jasio’s mother needs to take a toy car down.
3 2 7
1
2
3
1
3
1
2
4
Hint
Constraints: For of the testdata: , , .
Translated by ChatGPT 5
京公网安备 11011102002149号