Submission #873309

#TimeUsernameProblemLanguageResultExecution timeMemory
873309AndreibatmanArt Exhibition (JOI18_art)C++14
100 / 100
144 ms24916 KiB
#include <bits/stdc++.h> using namespace std; struct ceva { long long sz,val; }v[500010]; bool cmp(ceva a,ceva b) { return a.sz<b.sz; } long long n,i,sum,maxi,j,p[500010],pre=LLONG_MAX; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n; for(i=1;i<=n;i++) cin>>v[i].sz>>v[i].val; sort(v+1,v+n+1,cmp); for(i=1;i<=n;i++) { p[i]=p[i-1]+v[i].val; pre = min(pre, p[i-1]-v[i].sz); maxi=max(maxi,p[i]-v[i].sz-pre); } cout<<maxi; 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...