The maximum set

2.8

5 votes
Problem

You are given an array \(A\) of \(N\) integer elements. A pair of elements \((i,j)\) is said to be an inversion if \(A[i] > A[j]\) and \(i < j\) for all \(1 \le i,j \le N\).

Using this array \(A\), you create an undirected graph \(G\) of \(N\) vertices. For each inversion pair \((i,j)\), there exists an edge between vertex \(i\) and \(j\).

Find the maximum size of set \(S\) consisting of vertices from graph \(G\) such that there exists an edge between every pair of vertices present in \(S\).

Input format

  • The first line contains an integer \(T\) denoting the number of test cases.
  • The first line of each test case contains an integer \(N\).
  • The second line of each test case contains space-separated integers denoting array \(A\).

Output format

For each test case, print the maximum size of set \(S\) in a new line.

Constraints

\(1 \le T \le 10 \\ 1 \le N \le 10^5 \\ 1 \le A[i] \le 10^6\)

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Graph \(G\) is a complete graph, i.e. there exists an edge between every pair of vertex.

Thus, maximum size of set \(S\) is \(4\).

Editor Image

?