Submission #170637

#TimeUsernameProblemLanguageResultExecution timeMemory
170637mdn2002Art Exhibition (JOI18_art)C++14
100 / 100
526 ms48380 KiB
#include<bits/stdc++.h> using namespace std; const long long mod=998244353; long long n,ps[500005]; pair<long long,long long>a[500005]; multiset<long long>ms; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); //freopen(".in","r",stdin); //freopen(".out","w",stdout); cin>>n; for(int i=0;i<n;i++) { cin>>a[i].first>>a[i].second; } sort(a,a+n); for(int i=0;i<n;i++) { ps[i]=ps[i-1]+a[i].second; ms.insert(ps[i]-a[i].first); } long long ans=0; for(int i=0;i<n;i++) { ans=max(ans,*--ms.end()+a[i].first-ps[i-1]); ms.erase(ms.find(ps[i]-a[i].first)); } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...