Submission #873297

#TimeUsernameProblemLanguageResultExecution timeMemory
873297AndreibatmanArt Exhibition (JOI18_art)C++14
50 / 100
1040 ms20820 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; 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++) { sum=0; for(j=i;j<=n;j++) { sum=sum+v[j].val; maxi=max(maxi,sum-(v[j].sz-v[i].sz)); } } 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...