Submission #1037364

#TimeUsernameProblemLanguageResultExecution timeMemory
1037364ivazivaArt Exhibition (JOI18_art)C++14
50 / 100
330 ms29224 KiB
#include <bits/stdc++.h> using namespace std; #define MAXN 5001 long long n; vector<pair<long long,long long>> vec; long long pref[MAXN]; int main() { cin>>n; vec.push_back({0,0}); for (long long i=1;i<=n;i++) { long long a,b;cin>>a>>b; vec.push_back({a,b}); } sort(vec.begin(),vec.end()); pref[0]=0; for (long long i=1;i<=n;i++) pref[i]=pref[i-1]+vec[i].second; long long ans=-LLONG_MAX; for (long long i=1;i<=n;i++) { for (long long j=1;j<=i;j++) ans=max(ans,pref[i]-pref[j-1]-vec[i].first+vec[j].first); } cout<<ans<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...