# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
486855 | TypeYippie | Art Exhibition (JOI18_art) | C++14 | 0 ms | 204 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5+5;
int n;
pair<long long, long long> art[N];
long long pref[N];
int main(){
scanf("%d", &n);
for(int i = 1; i <= n; i++){
scanf("%lld%lld", &art[i].first, &art[i].second);
}
sort(art+1, art+n+1);
pref[0] = 0;
for(int i = 1; i <= n; i++){
pref[i] = pref[i-1]+art[i].second;
}
priority_queue<long long> pq;
long long ans = 0;
for(int i = n; i > 0; i--){
if(i < n){
ans = max(ans, (pq.top()-pref[i-1])+art[i].first);
}
pq.push(pref[i]-art[i].first);
}
printf("%lld\n", ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |