# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
170279 | Akashi | Art Exhibition (JOI18_art) | C++14 | 277 ms | 21112 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;
struct art{
long long x;
int y;
bool operator < (const art &aux)const{
if(x != aux.x) return x < aux.x;
return y < aux.y;
}
};
int n;
art a[500005];
int main()
{
scanf("%d", &n);
for(int i = 1; i <= n ; ++i)
scanf("%lld%d", &a[i].x, &a[i].y);
sort(a + 1, a + n + 1);
long long Sol = a[1].y, Sum = a[1].y, Max = a[1].x;
for(int i = 2; i <= n ; ++i){
Max = max(Max, -Sum + a[i].x);
Sum = Sum + a[i].y;
Sol = max(Sol, Sum + Max - a[i].x);
}
printf("%lld", Sol);
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... |