Submission #718187

#TimeUsernameProblemLanguageResultExecution timeMemory
718187Yell0Art Exhibition (JOI18_art)C++17
0 / 100
0 ms212 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> pll; const int MN=5e5+2; int N; pll a[MN]; ll v[MN],ans=0; int main() { ios::sync_with_stdio(0);cin.tie(0); cin>>N; for(int i=1;i<=N;++i) cin>>a[i].first>>a[i].second; sort(a+1,a+1+N); ll curr=a[1].second; for(int i=2;i<=N;++i) { ans=max(ans,curr); curr+=a[i].second-(a[i].first-a[i-1].first); if(curr<0) curr=a[i].second; ans=max(ans,curr); } cout<<ans<<'\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...