Submission #531978

#TimeUsernameProblemLanguageResultExecution timeMemory
531978nguyentunglamArt Exhibition (JOI18_art)C++14
100 / 100
586 ms24728 KiB
#include<bits/stdc++.h> #define forin(i, a, b) for(int i = a; i <= b; i++) #define forde(i, a, b) for(int i = a; i >= b; i--) #define fi first #define se second #define ll long long using namespace std; const int N = 5e5 + 10; pair<ll,ll> a[N]; ll res, s[N]; int main() { int n; cin >> n; forin(i, 1, n) cin >> a[i].fi >> a[i].se; sort(a+1, a+n+1); forin(i, 1, n) s[i] = s[i-1] + a[i].se; ll mini = s[0] - a[1].fi; forin(i, 2, n) { mini = min(mini, s[i-1] - a[i].fi); res = max(res, s[i] - a[i].fi -mini); } 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...