# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
785617 | gagik_2007 | Diversity (CEOI21_diversity) | C++17 | 1 ms | 212 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;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ff first
#define ss second
ll ttt;
const ll INF=1e18;
const ll MOD=1e9+7;
const ll N=300007;
ll n,m,k;
ll a[N];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
// freopen("output.txt","w",stdout);
// freopen("input.txt","r",stdin);
cin>>n>>m;
for(int i=0;i<n;i++){
int x;
cin>>x;
a[x]++;
}
cin>>m>>m;
vector<ll>d;
for(int i=0;i<N;i++){
if(a[i])d.push_back(a[i]);
}
ll ans=0;
for(int i=0;i<d.size();i++){
ans+=(d[i]*(d[i]+1))/2;
for(int j=1;i+j<d.size();j++){
ans+=d[i]*d[i+j]*(j+1);
}
}
cout<<ans<<endl;
}
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... |