Submission #985012

# Submission time Handle Problem Language Result Execution time Memory
985012 2024-05-17T09:30:11 Z alexdd Diversity (CEOI21_diversity) C++17
0 / 100
1 ms 2396 KB
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n,q;
int a[300005];
int fr[300005];
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n>>q;
    int mxm=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        fr[a[i]]++;
        mxm=max(mxm,a[i]);
    }
    int qle,qri;
    for(int i=1;i<=q;i++)
    {
        cin>>qle>>qri;
    }
    sort(fr+1,fr+1+mxm);
    vector<int> aux;
    for(int i=1;i<=mxm;i+=2)
    {
        aux.push_back(fr[i]);
    }
    for(int i=mxm-(1-mxm%2);i>0;i-=2)
    {
        aux.push_back(fr[i]);
    }
    long long pref=0,rez=0;
    for(auto x:aux)
    {
        rez += (pref+x)*(n-pref);
        rez -= x*(x-1)/2;
        pref += x;
    }
    cout<<rez;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -