Submission #887922

#TimeUsernameProblemLanguageResultExecution timeMemory
887922hafoArt Exhibition (JOI18_art)C++14
100 / 100
138 ms21264 KiB
#include <bits/stdc++.h> #define ll long long #define ull unsigned ll #define pb push_back #define pa pair<int, int> #define pall pair<ll, int> #define fi first #define se second #define TASK "test" #define Size(x) (int) x.size() #define all(x) x.begin(), x.end() using namespace std; template<typename T1, typename T2> bool mini (T1 &a, T2 b) {if(a > b) a = b; else return 0; return 1;} template<typename T1, typename T2> bool maxi (T1 &a, T2 b) {if(a < b) a = b; else return 0; return 1;} const int MOD = 1e9 + 7; const int LOG = 20; const int maxn = 5e5 + 7; const ll oo = 1e18 + 69; int n; pall a[maxn]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); //freopen(TASK".inp", "r", stdin); //freopen(TASK".out", "w", stdout); cin>>n; for(int i = 1; i <= n; i++) cin>>a[i].fi>>a[i].se; sort(a + 1, a + 1 + n); ll ans = 0, mn = oo, sum = 0; for(int i = 1; i <= n; i++) { mini(mn, sum - a[i].fi); sum += a[i].se; maxi(ans, sum - a[i].fi - mn); } cout<<ans; 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...