Submission #115328

#TimeUsernameProblemLanguageResultExecution timeMemory
115328model_codeHotel (CEOI11_hot)C++17
100 / 100
1744 ms39776 KiB
/* Model solution for task HOT * Author: Miroslaw Michalski * Time complexity : O(n log n) * 24APR11 * pure STL stuff */ #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 j = 0; j < m; j++) { int vj, dj; scanf("%d%d", &vj, &dj); q.push_back(make_pair(vj, dj)); } sort(q.begin(), q.end()); reverse(q.begin(), q.end()); for(int j = 0; j < m; j++) { int vj = q[j].first; int dj = q[j].second; map<pair<int, int>, int>::iterator it = v.lower_bound(make_pair(dj, -1)); if (it != v.end()) { if ((it->first).second < vj) { think.push_back(vj - (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 (stderr)

hot.cpp: In function 'int main()':
hot.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d", &n, &m, &o);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
hot.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &ci, &pi);
     ~~~~~^~~~~~~~~~~~~~~~~~
hot.cpp:34:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &vj, &dj);
     ~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...