# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
530535 | 2022-02-25T18:23:43 Z | peuch | Hotel (CEOI11_hot) | C++17 | 418 ms | 30000 KB |
#include<bits/stdc++.h> using namespace std; const int MAXN = 5e5 + 10; int n, m, o; pair<int, int> v[MAXN]; pair<int, int> p[MAXN]; vector<int> moedas; int main(){ scanf("%d %d %d", &n, &m, &o); for(int i = 1; i <= n; i++) scanf("%d %d", &v[i].second, &v[i].first); sort(v + 1, v + 1 + n); for(int i = 1; i <= m; i++) scanf("%d %d", &p[i].second, &p[i].first); sort(p + 1, p + 1 + m); int id = 1; multiset<int> s; for(int i = 1; i <= n; i++){ while(id <= m && p[id].first <= v[i].first){ s.insert(-p[id].second); id++; } if(!s.empty()){ moedas.push_back((*s.begin()) + v[i].second); s.erase(s.begin()); } } long long ans = 0; long long sum = 0; sort(moedas.begin(), moedas.end()); for(int i = 0; i < min(o, (int) moedas.size()); i++){ sum -= moedas[i]; ans = max(ans, sum); } printf("%lld\n", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 300 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 716 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 29 ms | 1600 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 52 ms | 2276 KB | Output is correct |
2 | Correct | 36 ms | 3244 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 151 ms | 4924 KB | Output is correct |
2 | Correct | 113 ms | 10940 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 315 ms | 9580 KB | Output is correct |
2 | Correct | 296 ms | 24140 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 388 ms | 13224 KB | Output is correct |
2 | Correct | 418 ms | 30000 KB | Output is correct |
3 | Correct | 359 ms | 26612 KB | Output is correct |