atcoder#ARC085D. [ARC085F] NRE
[ARC085F] NRE
Score : points
Problem Statement
You are given a sequence with all zeros, and a sequence consisting of and . The length of both is .
You can perform kinds of operations. The -th operation is as follows:
- Replace each of with .
Minimize the hamming distance between and , that is, the number of such that , by performing some of the operations.
Constraints
- consists of and .
- If , either or .
Input
Input is given from Standard Input in the following format:
Output
Print the minimum possible hamming distance.
3
1 0 1
1
1 3
1
If you choose to perform the operation, will become , for a hamming distance of .
3
1 0 1
2
1 1
3 3
0
If both operations are performed, will become , for a hamming distance of .
3
1 0 1
2
1 1
2 3
1
5
0 1 0 1 0
1
1 5
2
It may be optimal to perform no operation.
9
0 1 0 1 1 1 0 1 0
3
1 4
5 8
6 7
3
15
1 1 0 0 0 0 0 0 1 0 1 1 1 0 0
9
4 10
13 14
1 7
4 14
9 11
2 6
7 8
3 12
7 13
5
10
0 0 0 1 0 0 1 1 1 0
7
1 4
2 5
1 3
6 7
9 9
1 5
7 9
1