Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

#include <bits/stdc++.

h>

using namespace std;

int main()

int t;

cin >> t;

while (t--)

int n, x, s = 0;

cin >> n;

pair<int, int> k;

map<int, int> m;

for (int i = 0; i < n; i++)

cin >> x;

m[x]++;

for (auto i : m)

if (i.second > s)

s = i.second;

k = i;

if (k.second > (float)n / 2)

cout << k.first << endl;

else
cout << "NO" << endl;

You might also like