Submission #1114509

# Submission time Handle Problem Language Result Execution time Memory
1114509 2024-11-19T06:43:25 Z vjudge1 Diversity (CEOI21_diversity) C++17
0 / 100
1 ms 508 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
using pii=pair<int,int>;
signed main(){
  int n,q;
  cin>>n>>q;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  map<int,int>mp;
  vector<int>cnt;
  for(int i=0;i<n;i++){
    mp[a[i]]++;
  }
  int ans=0;
  for(auto[f,s]:mp){
    cnt.pb(s);
    ans+=s*(s-1)/2+s;
  }
  sort(cnt.begin(),cnt.end(),greater<int>());
  int inc1=cnt[0],inc2=cnt[0],sum=cnt[0];
  for(int i=1;i<n;i++){
    if(inc2<inc1)swap(inc1,inc2);
    ans+=cnt[i]*(inc1+sum);
    inc1+=sum+cnt[i];
    inc2+=(i+1)*cnt[i];
    sum+=cnt[i];
  }
  cout<<ans<<'\n';
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 508 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 508 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 508 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -