QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#197779#6965. Equalize the ArrayPPP#AC ✓74ms7016kbC++17880b2023-10-02 19:48:262023-10-02 19:48:26

Judging History

你现在查看的是最新测评结果

  • [2023-10-02 19:48:26]
  • 评测
  • 测评结果:AC
  • 用时:74ms
  • 内存:7016kb
  • [2023-10-02 19:48:26]
  • 提交

answer

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

#define X first
#define Y second

const ll mod = 1000000007;

void solve()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i=0;i<n;i++) cin >> a[i];
    sort(a.begin(),a.end());
    ll D = 0, MN = 0, MX = 0;
    for (ll i=0;i<n;i++)
    {
        D++;
        if (i==n-1 or a[i+1]!=a[i])
        {
            if (D==i+1) MN = D;
            MX = max(MX,D);
            D = 0;
        }
    }
    if (MN==MX) cout << "YES\n";
    else cout << "NO\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//#ifdef DEBUG
//    freopen("input.txt", "r", stdin);
//#endif
    ll T = 1;
    cin >> T;
    while (T--) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 74ms
memory: 7016kb

input:

105
500000
33226 432708 432708 432708 280629 33226 370163 182525 33226 33226 432708 432708 33226 33226 432708 432708 33226 33226 432708 33226 124133 432708 432708 33226 432708 33226 432708 33226 33226 33226 432708 432708 33226 432708 173002 432708 33226 33226 432708 33226 33226 33226 432708 432708 7...

output:

NO
NO
NO
NO
NO
YES
NO
YES
YES
NO
NO
YES
NO
YES
YES
NO
YES
YES
NO
NO
NO
YES
NO
YES
YES
YES
YES
NO
NO
NO
NO
NO
NO
YES
YES
YES
NO
NO
YES
NO
NO
NO
NO
NO
YES
YES
NO
YES
NO
NO
YES
YES
NO
YES
NO
NO
NO
NO
NO
NO
YES
YES
YES
NO
NO
YES
NO
YES
NO
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
YES
NO
NO
NO
NO
NO
YES
NO
YES
YES...

result:

ok 105 lines