Answer to Question #322346 in C++ for Abhik

Question #322346

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.


0
Service report
It's been a while since this question is posted here. Still, the answer hasn't been got. Consider converting this question to a fully qualified assignment, and we will try to assist. Please click the link below to proceed: Submit order

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS