# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1076118 | 2024-08-26T11:14:06 Z | lmaobruh | Art Exhibition (JOI18_art) | C++14 | 1 ms | 348 KB |
#include <bits/stdc++.h> using namespace std; #define ii pair<long long, long long> #define fi first #define se second const int N = 5e5+5; int n; ii a[N]; bool cmp(ii p1, ii p2) { if (p1 == p2) return 0; else if (p1 != p2) return p1.fi < p2.fi; else return p1.se > p2.se; } int main() { cin.tie(0)->sync_with_stdio(0); if (fopen("A.inp", "r")) freopen("A.inp", "r", stdin); cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i].fi >> a[i].se; sort(a+1, a+n+1, cmp); long long ans = a[1].se, mx = 0; for (int i = 1; i <= n; ++i) { ans = max(ans, mx - a[i].fi + a[i].se); mx = max(mx + a[i].se, a[i].fi + a[i].se); } cout << ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |