Submission #48930

#TimeUsernameProblemLanguageResultExecution timeMemory
48930faishol27Art Exhibition (JOI18_art)C++14
50 / 100
1078 ms12564 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define PUB push_back struct art{ ll sz, val; }; int N; ll pref[500005], ans = 0; vector<art> data; bool putus[500005]; bool comp(art a, art b){ if(a.sz == b.sz) return a.val < b.val; return a.sz < b.sz; } int main(){ cin >> N; data.PUB({0,0}); for(int i=1;i<=N;i++){ ll a, b; cin >> a >> b; data.PUB({a, b}); } sort(data.begin(), data.end(), comp); for(int i=1;i<=N;i++) pref[i] = pref[i-1]+data[i].val; for(int i=1;i<=N;i++) for(int j=i;j<=N;j++){ ll tmp = (pref[j]-pref[i-1])-(data[j].sz-data[i].sz); ans = max(ans, tmp); } 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...