Submission #1052462

#TimeUsernameProblemLanguageResultExecution timeMemory
1052462kunzaZa183Diversity (CEOI21_diversity)C++17
4 / 100
4 ms860 KiB
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0)->ios::sync_with_stdio(0); cin.exceptions(cin.failbit); int n,q; cin >> n>>q; vector<int> vi(n); for (auto &a : vi) cin >> a; for(int i=0;i<q;i++) { int l,r; cin>>l>>r; } map<int, int> mii; for (auto a : vi) mii[a]++; vector<pair<int, int>> vpii; for (auto a : mii) vpii.push_back(a); sort(vpii.begin(), vpii.end(), [](pair<int, int> a, pair<int, int> b) { return a.second > b.second; }); deque<int> di; for (int i = 0; i < vpii.size(); i++) if (i % 2 == 0) di.push_back(vpii[i].second); else di.push_front(vpii[i].second); int ans = 0; // for (auto a : di) // cout << a << ' '; // cout << "\n"; for (auto a : di) ans += a * (a + 1) / 2; // cout << ans << "\n"; for (int i = 0; i < di.size(); i++) for (int j = i + 1; j < di.size(); j++) { ans += di[i] * di[j] * (j - i + 1); } cout << ans << '\n'; }

Compilation message (stderr)

diversity.cpp: In function 'int main()':
diversity.cpp:25:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   for (int i = 0; i < vpii.size(); i++)
      |                   ~~^~~~~~~~~~~~~
diversity.cpp:37:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |   for (int i = 0; i < di.size(); i++)
      |                   ~~^~~~~~~~~~~
diversity.cpp:38:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for (int j = i + 1; j < di.size(); j++) {
      |                         ~~^~~~~~~~~~~
#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...