# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
895327 | 2023-12-29T18:53:42 Z | Isam | Art Exhibition (JOI18_art) | C++17 | 0 ms | 348 KB |
#include<bits/stdc++.h> using namespace std; constexpr int sz = 1e6 + 5; signed main(){ ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int N; cin >> N; vector<pair<int, int>> A(N+1); vector<long long> pref(N), cost(N); for(register int i(0); i < N; ++i){ cin >> A[i].first >> A[i].second; } sort(A.begin(), A.end()); for(register int i(0); i < N; ++i){ pref[i] = (i ? pref[i-1] : 0ll) + A[i].second; } for(register int i(N - 1); i >= 0; --i){ cost[i] = max((i < N - 1 ? cost[i+1] : -100000000), pref[i] - A[i].first); } long long ans{-1000000000}; for(register int i(0); i < N; ++i){ ans = max(ans, cost[i] - ((i ? pref[i-1] : 0ll) - A[i].first)); } cout << ans << '\n'; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |