Submission #1112906

#TimeUsernameProblemLanguageResultExecution timeMemory
11129060pt1mus23Schools (IZhO13_school)C++14
100 / 100
82 ms14464 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int #define ins insert #define pii pair<int,int> #define pb push_back #define endl '\n' #define putr(x) cout<<x<<endl;return; #define all(x) x.begin(),x.end() const int mod = 1e9 +7, sze = 2e5 +23, inf = LLONG_MAX, LG = 20; void fast(){ int n,m,s; cin>>n>>m>>s; vector<pii> arr(n+1); for(int i =1;i<=n;i++){ cin>>arr[i].first>>arr[i].second; } sort(arr.begin()+1,arr.end(),[&](pii a,pii b){ return a.second - a.first < b.second - b.first; }); vector<int> pref(n+10,0),suff(n+10,0); int ans=0,pf=0; priority_queue<int,vector<int>,greater<int>> q; for(int i =1;i<=n;i++){ pf+=arr[i].first; q.push(arr[i].first); if(q.size()>m){ pf-=q.top(); q.pop(); } pref[i]=pf; } while(!q.empty()) q.pop(); int sfa =0; for(int i = n;i>=1;i--){ sfa+=arr[i].second; q.push(arr[i].second); if(q.size()>s){ sfa-=q.top(); q.pop(); } suff[i]=sfa; } for(int i=1;i<=n;i++){ ans=max(ans,pref[i]+suff[i+1]); } putr(ans); } signed main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int tt = 1; // cin>>tt; while(tt--){ fast(); } return 0; }

Compilation message (stderr)

school.cpp: In function 'void fast()':
school.cpp:30:20: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   30 |         if(q.size()>m){
      |            ~~~~~~~~^~
school.cpp:41:20: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   41 |         if(q.size()>s){
      |            ~~~~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...