Submission #531971

#TimeUsernameProblemLanguageResultExecution timeMemory
531971nguyentunglamArt Exhibition (JOI18_art)C++14
0 / 100
0 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; forin(i, 1, n-1) { forin(j, i+1,n) { res = max(res, s[j] - s[i-1] - a[j].fi + 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...