This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
long long n,q;
long long nr, ans;
long long a[300005];
long long fr[300005];
bool comp(int a, int b)
{
return fr[a] > fr[b];
}
int main()
{
cin>>n>>q;
for(int i=1;i<=n;i++)
{
cin>>a[i];
fr[ a[i] ] ++;
}
int l, r;
cin>>l>>r;
sort(a+1, a+n+1, comp);
for(int i=1;i<=n;i++)
{
int nr=1;
for(int j=i;j<=n;j++)
{
if(i != j && a[j] != a[j-1])
nr++;
ans += nr;
}
}
cout<<ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |