Submission #1052465

#TimeUsernameProblemLanguageResultExecution timeMemory
1052465kunzaZa183Diversity (CEOI21_diversity)C++17
38 / 100
7068 ms13040 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed 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:26:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   for (int i = 0; i < vpii.size(); i++)
      |                   ~~^~~~~~~~~~~~~
diversity.cpp:38:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::deque<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |   for (int i = 0; i < di.size(); i++)
      |                   ~~^~~~~~~~~~~
diversity.cpp:39:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::deque<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     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...