2052: [USACO 2025 February Contest, Gold] Problem 1. Bessie's Function
题目描述
Bessie has a special function that takes as input an integer in and returns an integer in (). Her function is defined by integers where ().
Bessie wants this function to be idempotent. In other words, it should satisfy for all integers .
For a cost of , Bessie can change the value of to any integer in (). Determine the minimum total cost Bessie needs to make idempotent.
输入
The second line contains space-separated integers .
The third line contains space-separated integers .
输出
样例输入
5
2 4 4 5 3
1 1 1 1 1
样例输出
3
提示
We can change a1 = 4, a4 = 4, a5 = 4. Since all ci equal one, the total cost is equal to 3, the number of changes. It can be shown that there is no solution with only 2 or fewer changes.
8
1 2 5 5 3 3 4 4
9 9 2 5 9 9 9 9
7
We change and . The total cost is .
Subtasks:
Additionally, in each of the last three subtasks, the first half of tests will satisfy for all .
SAMPLE INPUT:
SAMPLE OUTPUT:
SCORING: