Submission #127105

#TimeUsernameProblemLanguageResultExecution timeMemory
127105eriksuenderhaufHotel (CEOI11_hot)C++11
100 / 100
1286 ms54488 KiB
//#pragma GCC optimize("O3") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define enl printf("\n") #define case(t) printf("Case #%d: ", (t)) #define ni(n) scanf("%d", &(n)) #define nl(n) scanf("%I64d", &(n)) #define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i]) #define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i]) #define pri(n) printf("%d\n", (n)) #define prl(n) printf("%lld\n", (n)) #define pii pair<int, int> #define pll pair<long long, long long> #define vii vector<pii> #define vi vector<int> #define pb push_back #define mp make_pair #define fi first #define se second using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef cc_hash_table<int,int,hash<int>> ht; const double pi = acos(-1); const int MOD = 1e9 + 7; const int INF = 1e9 + 7; const int MAXN = 1e6 + 5; const double eps = 1e-9; int c[MAXN], p[MAXN]; multiset<pii> st; vii a; vi ans; int main() { int n, m, o; ni(n), ni(m), ni(o); for (int i = 0; i < n; i++) { ni(c[i]), ni(p[i]); st.insert({p[i], c[i]}); } for (int i = 0; i < m; i++) { int v, d; ni(v), ni(d); a.pb({v, -d}); } sort(a.rbegin(), a.rend()); for (int i = 0; i < m; i++) { auto it = st.lower_bound({-a[i].se, -INF}); if (it == st.end()) continue; if (a[i].fi < it->se) continue; st.erase(it); ans.pb(a[i].fi - it->se); } sort(ans.rbegin(), ans.rend()); ll res = 0; for (int i = 0; i < min(o, (int) ans.size()); i++) res += (ll) ans[i]; prl(res); return 0; }

Compilation message (stderr)

hot.cpp: In function 'int main()':
hot.cpp:38:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     ni(n), ni(m), ni(o);
                 ^
hot.cpp:38:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
hot.cpp:38:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
hot.cpp:41:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         ni(c[i]), ni(p[i]);
                 ^
hot.cpp:41:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
hot.cpp:47:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         ni(v), ni(d);
              ^
hot.cpp:47:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
#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...