求 Hack
查看原帖
求 Hack
1334925
The_foolishest_OIer楼主2024/10/26 20:59

不知怎么就 8585 pts 了

#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n,sum,mi,mx;
int a[N],t[N];
int main(){
    cin >> n;
    mi = N + 10;
    for (int i = 1 ; i <= n ; i++){
        cin >> a[i];
        t[a[i]]++;
        mi = min(mi,a[i]);
        mx = max(mx,a[i]);
    }
    sum = n;
    for (int i = mi ; i <= mx ; i++){
        if (t[i] == 0) continue;
        if (t[i] > sum - t[i]){
            cout << t[i];
            return 0;
        }else{
            sum -= t[i];
            t[i] = 0;
        }
    }
    return 0;
}
2024/10/26 20:59
加载中...