# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
204700 | my99n | Art Exhibition (JOI18_art) | C++14 | 5 ms | 376 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;
pair<long long,long long> a[500100];
long long b[500100];
int main(){
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%lld %lld", &a[i].first, &a[i].second);
sort(a, a+n);
b[0] = a[0].second; long long ans = b[0];
for (int i = 1; i < n; i++) b[i] = a[i].second - a[i].first + a[i-1].first;
for (int i = 1; i < n; i++) b[i] += b[i-1], b[i] = b[i] < 0 ? 0 : b[i], ans = max(ans, b[i]);
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... |