# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
530097 | 2022-02-24T15:08:14 Z | buidangnguyen05 | Art Exhibition (JOI18_art) | C++14 | 0 ms | 332 KB |
/* input */ #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N = 5e5 + 10; ll pref[N], mx[N]; pair<ll, int> a[N]; signed main() { cin.tie(0)->sync_with_stdio(0); if (fopen("task.inp", "r")) { freopen("task.inp", "r", stdin); freopen("task.out", "w", stdout); } int n; cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i].first >> a[i].second; sort(a + 1, a + n + 1); for (int i = 1; i <= n; ++i) pref[i] = pref[i - 1] + a[i].second; for (int i = n; i; --i) mx[i] = max(mx[i + 1], pref[i] - a[i].first); ll res = 0; for (int i = 1; i <= n; ++i) res = max(res, a[i].first - pref[i - 1] + mx[i]); cout << res; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 332 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 332 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 332 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 332 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |