Submission #752931

#TimeUsernameProblemLanguageResultExecution timeMemory
752931bgnbvnbvArt Exhibition (JOI18_art)C++14
50 / 100
66 ms18560 KiB
#include<bits/stdc++.h> #define TASKNAME "codeforce" #define pb push_back #define pli pair<int,int> #define fi first #define se second #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); using namespace std; using ll=long long; const ll maxN=2e5; const ll inf=1e18; const ll mod=1e9+7; #define int ll ll a[maxN],pre[maxN],b[maxN],n,ans=-inf; void solve() { vector<pli>vec; cin >> n; for(int i=1;i<=n;i++) cin >> a[i] >> b[i],vec.pb({a[i],b[i]}); sort(vec.begin(),vec.end()); for(int i=1;i<=n;i++) { a[i]=vec[i-1].fi; b[i]=vec[i-1].se; } ll mn=inf; for(int i=1;i<=n;i++) { pre[i]=pre[i-1]+b[i]; mn=min(mn,pre[i-1]-a[i]); ans=max(ans,pre[i]-a[i]-mn); } cout << ans; } signed main() { fastio //freopen(TASKNAME".INP","r",stdin); //freopen(TASKNAME".OUT","w",stdout); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...