# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
48472 | arman_ferdous | Art Exhibition (JOI18_art) | C++17 | 2 ms | 248 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;
typedef long long ll;
const int N = 5e5+10;
pair<ll,ll> arr[N];
int main() {
int n, L = 0;
scanf("%d", &n);
for(int i = 0; i < n; i++)
scanf("%lld %lld", &arr[i].first, &arr[i].second);
sort(arr,arr+n);
ll ans = 0, sum = 0;
while(L+1 < n && arr[L+1].first >= arr[L].first + arr[L].second) L++;
for(int R = L; R < n; R++) {
sum += arr[R].second;
ans = max(ans, sum - arr[R].first + arr[L].first);
}
printf("%lld", 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... |