# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
330733 | M_W | Art Exhibition (JOI18_art) | C++14 | 1 ms | 364 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;
#define ii pair<long long, long long>
ii aw[500500];
long long val[500500];
int main(){
int N;
scanf("%d", &N);
for(int i = 0; i < N; i++)
scanf("%lld %lld", &aw[i].first, &aw[i].second);
sort(aw, aw + N);
val[0] = aw[0].second;
for(int i = 1; i < N; i++)
val[i] = aw[i].second - (aw[i].first - aw[i - 1].first);
long long curmax = 0, maxmax = INT_MIN;
for(int i = 0; i < N; i++){
curmax = max(curmax + val[i], 0 * 1ll);
maxmax = max(maxmax, curmax);
}
printf("%lld", maxmax);
}
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... |