Submission #90920

#TimeUsernameProblemLanguageResultExecution timeMemory
90920kylych03Schools (IZhO13_school)C++14
30 / 100
75 ms13560 KiB
#include <bits/stdc++.h> #define int long long #define sc second #define fr first using namespace std; pair <int, pair<int, int> > ar[100001]; int pr[100002], sf[100002]; multiset <int> st1, st2; main() { int n,a,b; cin>>n>>a>>b; for(int i=0;i<n;i++){ cin>>ar[i].sc.fr>>ar[i].sc.sc; ar[i].fr=ar[i].sc.sc - ar[i].sc.fr; } sort(ar,ar+n); int sum=0; for(int i=0;i<n;i++){ if(i<a){ sum+=ar[i].sc.fr; pr[i]=sum; st1.insert(ar[i].sc.fr); } else{ sum+=ar[i].sc.fr; st1.insert(ar[i].sc.fr); sum-=(*st1.begin()); pr[i]=sum; st1.erase(*st1.begin()); } } sum=0; for(int i=n-1;i>=0;i--){ if(n-b <= i){ sum+=ar[i].sc.sc; sf[i]=sum; st2.insert(ar[i].sc.sc); } else{ sum+=ar[i].sc.sc; st2.insert(ar[i].sc.sc); sum-=(*st2.begin()); sf[i]=sum; st2.erase(*st2.begin()); } } int mx=-10000000000000; for(int i=0;i<n;i++) mx=max(pr[i] + sf[i+1],mx); cout<<mx<<endl; }

Compilation message (stderr)

school.cpp:11:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...