| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 943522 | vjudge1 | Art Exhibition (JOI18_art) | C++17 | 2 ms | 348 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>
# define pb push_back
# define ff first
# define ss second
# define nl "\n"
# define sz(x) ((int)(x).size())
# define all(x) (x).begin(), (x).end()
# define deb(x) cerr << #x << " = " << x << endl;
# define pll pair <ll, ll>
# define pii pair <int, int>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll maxn = (ll)5e5 + 3;
const ll inf = (ll)2e18 + 0;
const ll mod = (ll)1e9 + 7;
const ll dx[] = {-1, 1, 0, 0};
const ll dy[] = {0, 0, -1, 1};
const bool T = 0;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void Freopen () {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
int n;
pll p[maxn];
ll pref[maxn];
void ma1n () {
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> p[i].ff >> p[i].ss;
}
sort(p + 1, p + 1 + n);
// for (int i = 1; i <= n; ++i) {
// cout << p[i].ff << ' ' << p[i].ss << nl;
// }
ll ans = 0, mx = -inf;
for (int i = 1; i <= n; ++i) {
mx = max(mx, -pref[i - 1] + p[i].ff);
pref[i] = pref[i - 1] + p[i].ss;
ll cur = pref[i] - p[i].ff + mx;
// cout << i << ' ' << cur << ' ' << mx << nl;
ans = max(ans, cur);
}
cout << ans << nl;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
Freopen();
int ttt = 1;
if (T) cin >> ttt;
for (int test = 1; test <= ttt; ++test) {
// cout << "Case " << test << ":" << '\n';
ma1n();
}
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... | ||||
