# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
973860 | 2024-05-02T11:59:10 Z | Hectorungo_18 | Art Exhibition (JOI18_art) | C++14 | 1 ms | 348 KB |
#include <iostream> #include <bits/stdc++.h> #include <list> #include <set> #include <cstdio> using namespace std; #define int unsigned long long #define f first #define s second #define all(x) x.begin(), x.end() void solve(){ int n; cin >> n; vector<pair<int, int>> v(n); for(int i = 0; i < n; i++) cin >> v[i].f >> v[i].s; sort(all(v)); vector<pair<int, int>> w; for(int i = 0; i < n; i++){ if(w.size() == 0 || v[i].f != w.back().f){ w.push_back(v[i]); } else{ w.back().s+=v[i].s; } } v = w; int ans = v[0].s; int bf = v[0].f; int cur = v[0].s; for(int i = 1; i < v.size(); i++){ int ad = v[i].s; int re = v[i].f-v[i-1].f; if(cur+ad-re < 0){ cur = ad; ans = max(ans, cur); continue; } cur+=ad-re; ans=max(ans, cur); } cout << ans << endl; } signed main() { int t = 1; // cin >> t; while(t--) solve(); return 0; }
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 | - |