Source Code
#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(),x.end()
#define pb push_back
#define pf push_front
#define eb emplace_back
#define rep(i, b, n) for(int i=b; i < n ; i++)
#define rev(i, n, b) for(int i = n; i>= b; i--)
#define ll long long
#define F first
#define S second
#define endl "\n"
#define int ll
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define ali "Alice."
#define bob "Bob."
#define OO 0x3f3f3f3f3f3f3f3f
int dx[] = {+0, +0, -1, +1, +1, +1, -1, -1};
int dy[] = {-1, +1, +0, +0, +1, -1, +1, -1};
int kdx[] = {2, 1, -1, -2, -2, -1, 1, 2};
int kdy[] = {1, 2, 2, 1, -1, -2, -2, -1};
const double Pi = 3.14159265358979323846264;

bool cmp(const pair<int, int> &a, const pair<int, int> &b) {
    return a.second > b.second;
}

const int mod = 1e9 + 7, N = 1e5;

void solve() {
    int n; cin >> n;
    vector<int> v(n);
    map<int,int> m;
    for(int i = 0; i <n; i++) {
        cin >> v[i];
        m[v[i]]++;
    }
    sort(all(v));
    reverse(all(v));
    cout << n - m[v[0]]+1 << endl;
}


signed main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#ifdef Clion
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t(1);
    cin >> t;
    for (int i = 1; i <= t; i++) {
        solve();
    }
}
Copy
Proud Competitors Mnesy
GNU G++17
32 ms
312 KB
Wrong Answer