Orig Description
Score : 300 points
Problem StatementA sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied:
For each i = 1,2,..., n-2, a_i = a_{i+2}.
Exactly two different numbers appear in the sequence.
You are given a sequence v_1,v_2,...,v_n whose length is even.
We would like to make this sequence /\/\/\/ by replacing some of its elements.
Find the minimum number of elements that needs to be replaced.
Constraints
2 \leq n \leq 10^5
n is even.
1 \leq v_i \leq 10^5
v_i is an integer.
InputInput is given from Standard Input in the following format:
n
v_1 v_2 ... v_n
OutputPrint the minimum number of elements that needs to be replaced.
Sample Input 14
3 1 3 2
Sample Output 11
The sequence 3,1,3,2 is not /\/\/\/, but we can make it /\/\/\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.
Sample Input 26
105 119 105 119 105 119
Sample Output 20
The sequence 105,119,105,119,105,119 is /\/\/\/.
Sample Input 34
1 1 1 1
Sample Output 32
The elements of the sequence 1,1,1,1 are all the same, so it is not /\/\/\/.
Extracted Specification
An integer N (2 ≤ N ≤ 10^5), representing some quantity or size. N is even.
A list of integers V of size N, where each integer is between 1 and 1e5.
### Example Input:
```
4
3 1 3 2
```
### Function Signature:
Write a function f(N, V) that takes in the input.
def f(N: int, V: List[int]):
'''
N: an integer
V: a list of integers
'''
Test Case Generator
Sure, I can help write a test case generator for the given problem. Here's the Python code to generate test cases for the problem:
```python
import random
def generate_test_case():
n = random.randint(2, 10**5)
if n % 2 != 0:
n += 1 # Ensure that n is even
v = [random.randint(1, 10**5) for _ in range(n)]
return n, v
# Function to format the test case for output
def format_test_case(n, v):
return f"{n}\n{' '.join(map(str, v))}"
# Example of generating and printing a test case
if __name__ == "__main__":
n, v = generate_test_case()
print(format_test_case(n, v))
```
### Explanation:
1. **n Generation**: We generate `n` such that `2 ≤ n ≤ 10^5` and ensure `n` is even.
2. **v Generation**: We generate a list `v` of size `n` where each element is an integer between `1` and `10^5`.
3. **Formatting**: The function `format_test_case` takes the generated `n` and `v` and formats them for output.
4. **Example Usage**: The main block demonstrates how to generate and print a test case.
This generator will create random valid input test cases for the problem statement provided.
Extract Arguments
def extract_arguments(fh):
n = int(fh.readline().strip())
v = list(map(int, fh.readline().strip().split()))
return n, v