# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
672132 | Stavab | Art Exhibition (JOI18_art) | C++14 | 0 ms | 212 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 <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
int main()
{
int n;
scanf("%d", &n);
vector<pair<long long, long long>> v(n);
for(int i = 0; i < n; i++)
{
scanf("%lld", &v[i].first);
scanf("%lld", &v[i].second);
}
sort(v.begin(), v.end());
long long best = -1;
long long sum = 0;
for(int i = 0; i < n; i++)
{
sum += v[i].second;
best = max(best, sum - v[i].first);
}
long long temp = 0;
sum = 0;
for(int i = 0; i < n; i++)
{
best = max(best, best - sum + v[i].first - temp);
sum += v[i].second;
temp = v[i].first;
}
printf("%lld\n", best);
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... |