Submission #785892

#TimeUsernameProblemLanguageResultExecution timeMemory
785892OzyDiversity (CEOI21_diversity)C++17
0 / 100
1 ms324 KiB
#include <iostream> #include <bits/stdc++.h> using namespace std; #define lli long long int #define debug(a) cout << #a << " = " << a << endl #define debugsl(a) cout << #a << " = " << a << ", " #define rep(i,a,b) for(int i = (a); i <= (b); i++) #define repa(i,a,b) for(int i = (a); i >= (b); i--) #define MAX 300000 lli n,a,res,q; lli arr[MAX+2],vis[MAX+2]; vector<lli> frec; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> q; rep(i,1,n) { cin >> arr[i]; vis[arr[i]]++; } rep(i,1,n) { if (vis[i] == 0) continue; frec.push_back(vis[i]); vis[i] = 0; } sort(frec.begin(), frec.end()); //lee la pregunta lli x,y; cin >> x >> y; lli sum = 0; lli glob = 0; for(auto act : frec) { res += glob*act; x = act*(act+1)/2; res += x; sum += act; glob += sum + act; //debug(res); } cout << res; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...