# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
860161 | 2023-10-11T21:06:25 Z | lovrot | Hotel (CEOI11_hot) | C++17 | 724 ms | 66856 KB |
#include <cstdio> #include <vector> #include <algorithm> #include <set> #define X first #define Y second #define EB emplace_back #define MP make_pair using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; int n, m, k; multiset<pll> A; vector<pll> B; vector<ll> ANS; int main() { scanf("%d%d%d", &n, &m, &k); for(int i = 0; i < n; ++i) { int a, b; scanf("%d%d", &a, &b); A.insert({b, a}); } for(int i = 0; i < m; ++i) { int a, b; scanf("%d%d", &a, &b); B.EB(MP(a, b)); } sort(B.begin(), B.end(), [](pll a, pll b) { return a.X > b.X || (a.X == b.X && a.Y < b.Y); }); for(pll p : B) { auto lb = A.lower_bound(MP(p.Y, 0)); if(lb != A.end()) { ANS.EB(p.X - (*lb).Y); A.erase(lb); } } sort(ANS.begin(), ANS.end(), [](ll a, ll b) { return a > b; }); ll ans = 0; for(int i = 0; i < min(k, (int) ANS.size()) && ANS[i] > 0; ++i) ans += ANS[i]; printf("%lld\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 1112 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 36 ms | 4504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 59 ms | 7332 KB | Output is correct |
2 | Correct | 45 ms | 7876 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 190 ms | 20092 KB | Output is correct |
2 | Correct | 100 ms | 15556 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 472 ms | 39340 KB | Output is correct |
2 | Correct | 557 ms | 54984 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 575 ms | 47300 KB | Output is correct |
2 | Correct | 636 ms | 66856 KB | Output is correct |
3 | Correct | 724 ms | 63920 KB | Output is correct |