#P10647. [NordicOI 2023] Ice Cream Machines
[NordicOI 2023] Ice Cream Machines
Background
Translated from NordicOI 2023 Problem B Ice Cream Machines。
Problem Description
In your ice cream shop, there are customers waiting in a line. The shop offers flavors in total. Everyone has a flavor they want to buy, but unfortunately, the shop only has machines and cannot provide all flavors at the same time. Therefore, if the next customer wants a flavor different from the one currently in a machine, they must clean that machine and switch it to their preferred flavor.
Now these people buy ice cream in order from . As a very smart shop owner, you need to decide which machine each person should use so that the number of cleanings is minimized. Output this minimum number.
Note: If a machine has not been used by anyone before, it is considered to require cleaning by default (if it is never used at all from start to finish, then no cleaning is needed).
Input Format
The first line contains three integers , , and , representing that there are people in total, the shop has ice cream flavors, and there are machines.
Then follow lines, each containing an integer , indicating the flavor ID liked by the -th person.
Output Format
Output the minimum number of cleanings required.
8 3 1
2
3
3
1
2
1
1
3
6
8 3 2
2
3
3
1
2
1
1
3
4
Hint
This problem uses bundled testdata.
- Subtask 1 (7 points): , , .
- Subtask 2 (12 points): , , .
- Subtask 3 (22 points): , , .
- Subtask 4 (11 points): , , .
- Subtask 5 (14 points): , , .
- Subtask 6 (13 points): , , .
- Subtask 7 (21 points): No additional constraints.
For all testdata, , , , .
Translated by ChatGPT 5