# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1234781 | Jer | Art Exhibition (JOI18_art) | C++20 | 15 ms | 1876 KiB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 5;
int n;
pair<ll, ll> a[MAXN];
ll pre[MAXN];
#define ff first
#define ss second
int main()
{
scanf("%d", &n);
ll f, s;
for (int i = 0; i < n; i++)
scanf("%lld%lld", &f, &s), a[i] = {f, s};
sort(a, a + n);
for (int i = 0; i < n; i++)
pre[i] = (i == 0) ? a[i].ss : a[i].ss + pre[i - 1];
ll res = 0;
for (int i = 0; i < n; i++)
for (int j = i; j < n; j++)
{
ll sum = (i == 0) ? pre[j] : pre[j] - pre[i - 1];
res = max(res, sum - (a[j].ff - a[i].ff));
}
printf("%lld\n", res);
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... |