Submission #679366

# Submission time Handle Problem Language Result Execution time Memory
679366 2023-01-08T07:17:23 Z Duy_e Stove (JOI18_stove) C++14
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair <ll, ll>
#define st first
#define nd second
#define rep(i, n, m) for (ll i = (n); i <= (m); i ++)
#define rrep(i, m, n) for (ll i = (m); i >= (n); i --)

using namespace std;
const long long N = 2e5 + 5;

ll n, f[N];
pii a[N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> n;
    rep(i, 1, n) cin >> a[i].st >> a[i].nd;

    sort(a + 1, a + 1 + n);

    ll ans = 0;

    ll mi = -a[1].st;

    rep(i, 1, n) {
        f[i] = f[i - 1] + a[i].nd;
        ll p = f[i] - a[i].st;
        ans = max(ans, p - mi);
        mi = min(mi, f[i] - a[i + 1].st);
    }

    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -