Submission #52347

#TimeUsernameProblemLanguageResultExecution timeMemory
52347tmwilliamlin168Art Exhibition (JOI18_art)C++14
100 / 100
117 ms8572 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pll pair<ll, ll> #define fi first #define se second inline ll in() { ll result = 0; char ch = getchar_unlocked(); while(true) { if(ch >= '0' && ch <= '9') break; ch = getchar_unlocked(); } result = ch-'0'; while(true) { ch = getchar_unlocked(); if (ch < '0' || ch > '9') break; result = result*10 + (ch - '0'); } return result; } inline void out(ll x) { ll rev=x; int c=0; while(!(rev%10)) { ++c; rev/=10; } rev=0; while(x) { rev=rev*10+x%10; x/=10; } while(rev) { putchar_unlocked(rev%10+'0'); rev/=10; } while(c--) putchar_unlocked('0'); } const int mxN=5e5; int n; ll mx, ans; pll ps[mxN+1]; int main() { n=in(); for(int i=1; i<=n; ++i) ps[i].fi=in(), ps[i].se=in(); sort(ps, ps+n+1); for(int i=1; i<=n; ++i) { ps[i].se+=ps[i-1].se; mx=max(ps[i].fi-ps[i-1].se, mx); ans=max(ps[i].se-ps[i].fi+mx, ans); } out(ans); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...