# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1087033 | quangminh412 | Art Exhibition (JOI18_art) | C++14 | 1034 ms | 20868 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;
/*
John Watson
https://codeforces.com/profile/quangminh98
Mua Code nhu mua Florentino !!
*/
#define faster() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
const ll oo = 1e18;
const int maxn = 5e5 + 9;
int n;
pair<ll, ll> a[maxn];
signed main()
{
if (fopen("test.inp", "r"))
{
freopen("test.inp", "r", stdin);
freopen("test.out", "w", stdout);
}
faster();
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i].first >> a[i].second;
// first: size
// second: value
sort(a + 1, a + n + 1);
ll ans = -oo;
for (int i = 1; i <= n; i++)
{
ll mn = a[i].first, mx = a[i].first;
ll s = 0;
for (int j = i; j >= 0; j--)
{
mn = a[j].first;
s += a[j].second;
ans = max(ans, s - (mx - mn));
}
}
cout << ans << '\n';
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... |