Submission #620801

#TimeUsernameProblemLanguageResultExecution timeMemory
620801berrNewspapers (CEOI21_newspapers)C++17
0 / 100
6 ms5204 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); vector<int> a(300005, 0); int n, q; cin>>n>>q; for(int i=0; i<n; i++) { int x; cin>>x; a[x]++; } sort(a.begin(), a.end()); int ans=0; vector<int> b, c; for(int i=0; i<a.size(); i++) { if(a[i]>0) { if(i%2) b.push_back(a[i]); else c.push_back(a[i]); } } int l, r; cin>>l>>r; reverse(c.begin(), c.end()); for(auto i: c) b.push_back(i); int sum=0, all=0; for(int i=0; i<b.size(); i++) { sum+=all; ans+=sum*b[i]+(b[i]*(b[i]+1))/2; all+=b[i]; sum+=b[i]; } cout<<ans; }

Compilation message (stderr)

newspapers.cpp: In function 'int32_t main()':
newspapers.cpp:21:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for(int i=0; i<a.size(); i++)
      |                  ~^~~~~~~~~
newspapers.cpp:36:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for(int i=0; i<b.size(); i++)
      |                  ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...