Submission #531976

#TimeUsernameProblemLanguageResultExecution timeMemory
531976nguyentunglamArt Exhibition (JOI18_art)C++17
0 / 100
1 ms204 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) { res = max(res, s[i] - a[i].fi -mini); mini = min(mini, s[i-1] - a[i].fi); } 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...