Submission #1048147

#TimeUsernameProblemLanguageResultExecution timeMemory
104814712345678Diversity (CEOI21_diversity)C++17
0 / 100
1 ms2508 KiB
#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)

diversity.cpp: In function 'int main()':
diversity.cpp:26:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::map<long long int, long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for (int i=1; i<=mp.size(); i++) v[i]+=v[i-1];
      |                   ~^~~~~~~~~~~
diversity.cpp:27:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::map<long long int, long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for (int i=1; i<=mp.size(); i++) res+=v[i-1]*(n-v[i]);
      |                   ~^~~~~~~~~~~
#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...