# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
115330 | 2019-06-06T17:24:28 Z | model_code | Hotel (CEOI11_hot) | C++17 | 1694 ms | 39492 KB |
/* Model solution for task HOT * Author: Miroslaw Michalski * Time complexity : O(n log n) * 24APR11 * pure STL stuff * when equal room sizes sort in rev. order */ #include <cstdio> #include <vector> #include <set> #include <map> #include <algorithm> #include <iostream> using namespace std; int main() { int n, m, o, ci, pi; long long res = 0; vector<int> think; map<pair<int, int>, int > v; scanf("%d%d%d", &n, &m, &o); for(int i = 0; i < n; i++) { scanf("%d%d", &ci, &pi); pair<int, int> obj = make_pair(pi, ci); if (v.find(obj) == v.end()) { v[obj] = 1; } else { v[obj]++; } } vector<pair<int, int> > q; for(int i = 0; i < m; i++) { scanf("%d%d", &ci, &pi); q.push_back(make_pair(ci, -pi)); } sort(q.begin(), q.end()); reverse(q.begin(), q.end()); for(int i = 0; i < m; i++) { ci = q[i].first; pi = -q[i].second; map<pair<int, int>, int>::iterator it = v.lower_bound(make_pair(pi, -1)); if (it != v.end()) { if ((it->first).second < ci) { think.push_back(ci - (it->first).second); } if (it->second == 1) { v.erase(it); } else { v[it->first] --; } } } sort(think.begin(), think.end()); reverse(think.begin(), think.end()); o = min(o, static_cast<int>(think.size())); for(int i = 0; i < o; i++) { res += think[i]; } printf("%lld\n", res); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 1024 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 66 ms | 3472 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 126 ms | 5920 KB | Output is correct |
2 | Correct | 103 ms | 5424 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 457 ms | 15968 KB | Output is correct |
2 | Correct | 195 ms | 8380 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1014 ms | 31872 KB | Output is correct |
2 | Correct | 1237 ms | 29752 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 998 ms | 23760 KB | Output is correct |
2 | Correct | 1268 ms | 39096 KB | Output is correct |
3 | Correct | 1694 ms | 39492 KB | Output is correct |