# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
813557 | manhlinh1501 | Art Exhibition (JOI18_art) | C++17 | 2 ms | 340 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.
/// @author : Hoang Manh Linh
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 5;
using i64 = long long;
using pll = pair<i64, i64>;
int n;
pll a[MAXN];
i64 sum[MAXN];
i64 ans = 0;
int main(int argc, char **argv) {
if(fopen(".inp", "r")) {
freopen(".inp", "r", stdin);
freopen(".out", "w", stdout);
}
#ifndef ONLINE_JUDGE
freopen("test.inp", "r", stdin);
#endif // ONLINE_JUDGE
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for(int i = 1; i <= n; i++)
cin >> a[i].first >> a[i].second;
sort(a + 1, a + n + 1);
for(int i = 1; i <= n; i++)
sum[i] = sum[i - 1] + a[i].second;
for(int i = 1; i <= n; i++) {
for(int j = i; j <= n; j++)
ans = max(ans, (sum[j] - sum[i - 1]) - (a[j].first - a[i].first));
}
cout << ans;
}
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... |