# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1076152 | lmaobruh | Art Exhibition (JOI18_art) | C++14 | 481 ms | 46308 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;
#define ll long long
#define int long long
#define ii pair<ll, ll>
#define fi first
#define se second
const int N = 5e5+5;
int n;
ii a[N];
map<ll, ll> mp;
int32_t main() {
cin.tie(0)->sync_with_stdio(0);
if (fopen("A.inp", "r")) {
freopen("A.inp", "r", stdin);
freopen("A.out", "w", stdout);
}
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> a[i].fi >> a[i].se;
mp[a[i].fi] += a[i].se;
}
n = 0;
for (auto &it : mp) a[++n] = it;
sort(a+1, a+n+1);
long long ans = 0, mx = 0;
for (int i = 1; i <= n; ++i) {
ans = max(ans, mx - a[i].fi + a[i].se);
ans = max(ans, a[i].se);
mx = max(mx + a[i].se, a[i].fi + a[i].se);
}
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... |