Polycarp concocted his rule for the excellence of a cluster. He considers a cluster an excellent if somewhere around one of the accompanying conditions should be met for each unique pair of lists i≠j: Computer based intelligence is detachable by aj; or then again aj is distinguishable by artificial intelligence.
Correct answer will be upvoted else downvoted. Computer science.
Polycarp concocted his rule for the excellence of a cluster. He considers a cluster an excellent if somewhere around one of the accompanying conditions should be met for each unique pair of lists i≠j:
Computer based intelligence is detachable by aj;
or then again aj is distinguishable by
For instance, if:
n=5 and a=[7,9,3,14,63], then, at that point, the a cluster isn't excellent (for i=4 and j=2, none of the conditions above is met);
n=3 and a=[2,14,42], then, at that point, the a cluster is excellent;
n=4 and a=[45,9,3,18], then, at that point, the a cluster isn't excellent (for i=1 and j=4 none of the conditions above is met);
Appalling exhibits upset Polycarp, so he needs to eliminate a few components from the cluster a with the goal that it becomes lovely. Assist Polycarp with deciding the most modest number of components to eliminate to make the exhibit a wonderful.
Input
The primary line contains one integer t (1≤t≤10) — the number of experiments. Then, at that point, t experiments follow.
The principal line of each experiment contains one integer n (1≤n≤2⋅105) — the length of the exhibit a.
The second line of each experiment contains n numbers a1,a2,… ,an (1≤ai≤2⋅105) — components of the exhibit a.
Output
For each experiment output one integer — the base number of components that should be eliminated to make the exhibit an excellent.
Step by step
Solved in 4 steps with 1 images