# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
481152 | aris12345678 | Art Exhibition (JOI18_art) | C++14 | 1097 ms | 24504 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;
typedef pair<ll, int> pli;
#define X first
#define Y second
const int mxN = 500005;
pli arr[mxN];
ll pref[mxN];
int main() {
int n;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
scanf("%lld %d", &arr[i].X, &arr[i].Y);
sort(arr+1, arr+n+1);
for(int i = 1; i <= n; i++)
pref[i] = 1LL*arr[i].Y+pref[i-1];
ll ans = 0;
for(int i = 1; i <= n; i++) {
for(int j = i; j <= n; j++) {
ans = max(ans, (pref[j]-pref[i-1])-(arr[j].X-arr[i].X));
// cout << i << " " << j << " " << ans << " " << (pref[j]-pref[i-1])-(arr[j].X-arr[i].X) << "\n";
}
}
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... |