Bhaskar found an array A of size n and wants to find a subsequence of the array which is good.
A subsequence is a sequence that can be derived from the given array by deleting zero or more elements without changing the relative order of the remaining elements.
A good subsequence meets following:
The length of the subsequence is even.
let the subsequence be B of size t, where t is even, So let the function f[i] = B[2*i] + B[2*i + 1] for all i from 0 to t2−1 both inclusive. Please note that indexing is zero-based here. So Sotwik wants all the f[i] to be same. In other words f[0] = f[1] = ... = f[t2−1] should hold.
As Bhaskar wants to utilize the whole array and delete as fewer elements as possible. He needs your help in finding the minimum number of elements that are required to be deleted such that the remaining subsequence is a good subsequence.
Input
n is the size of array. Second line has elements of array A of size n.
Output
Print a single integer denoting the minimum number of deletions required.
Comments
Leave a comment