Submission #679368

#TimeUsernameProblemLanguageResultExecution timeMemory
679368Duy_eArt Exhibition (JOI18_art)C++14
50 / 100
83 ms9932 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...