Submission #75212

#TimeUsernameProblemLanguageResultExecution timeMemory
75212vexArt Exhibition (JOI18_art)C++14
100 / 100
275 ms92276 KiB
#include <bits/stdc++.h> #define maxn 500005 #define pll pair<long long,long long> #define f first #define s second using namespace std; int n; pll a[maxn]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin>>n; for(int i=0;i<n;i++)cin>>a[i].f>>a[i].s; sort(a,a+n); for(int i=1;i<n;i++)a[i].s+=a[i-1].s; long long sol=a[0].s; long long minn=-a[0].f; for(int i=1;i<n;i++) { long long x=a[i].s-a[i].f; if(a[i-1].s-a[i].f<minn)minn=a[i-1].s-a[i].f; x-=minn; if(sol<x)sol=x; } cout<<sol<<endl; 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...