Submission #798418

#TimeUsernameProblemLanguageResultExecution timeMemory
798418AlkaratArt Exhibition (JOI18_art)C++14
100 / 100
161 ms20856 KiB
#include <bits/stdc++.h> #define ll long long #define f first #define s second const int N=5e5+10; using namespace std; int n; pair<ll,ll>p[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n; for(int i=1; i<=n; i++) cin>>p[i].f>>p[i].s; sort(p+1,p+n+1); for(int i=1; i<=n; i++) p[i].s+=p[i-1].s; ll mn=-p[1].f,res=0; for(int i=1; i<=n; i++) { res=max(res,-p[i].f+p[i].s-mn); mn=min(mn,-p[i+1].f+p[i].s); } cout<<res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...