# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1048147 | 12345678 | Diversity (CEOI21_diversity) | C++17 | 1 ms | 2508 KiB |
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;
#define ll long long
const int nx=3e5+5;
ll n, a[nx], v[nx], q, l, r, c, d, t, res;
map<ll, ll> mp;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>q;
for (int i=1; i<=n; i++) cin>>a[i], mp[a[i]]++;
cin>>c>>d;
l=1, r=mp.size();
for (auto [x, y]:mp)
{
t++;
res+=y*(n-y)+y*(y+1)/2;
if (t%2) v[l++]=y;
else v[r--]=y;
}
for (int i=1; i<=mp.size(); i++) v[i]+=v[i-1];
for (int i=1; i<=mp.size(); i++) res+=v[i-1]*(n-v[i]);
cout<<res;
}
Compilation message (stderr)
# | 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... |