Submission #482092

#TimeUsernameProblemLanguageResultExecution timeMemory
482092NeosHotel (CEOI11_hot)C++14
100 / 100
1146 ms60804 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<ll, ll> ii; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<ii> vii; typedef vector<vi> vvi; typedef vector<vll> vvll; typedef vector<vii> vvii; #define task "test" #define fastIO ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL) #define forw(i, l, r) for( ll i = (l) ; i < (r) ; i++ ) #define forb(i, r, l) for( ll i = (r) ; i >= (l) ; i-- ) #define numBit(x) (__builtin_popcountll(1ll * (x))) #define getBit(x, i) ((x) >> (i) & 1) #define sz(x) (int)x.size() #define mp make_pair #define fi first #define se second #define ar array #define pb push_back #define pf push_front #define pob pop_back #define pof pop_front #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define debug(x) cerr << #x << " = " << x << '\n'; const int N = 5e5 + 7; const ll inf = 0x3f3f3f3f; template<typename T> bool scan(T &num) { num = 0; register char c = getchar(); while (c != '-' && (c < '0' || '9' < c)) { if (feof(stdin)) return false; c = getchar(); } bool neg = false; if (c == '-') { neg = true; c = getchar(); } for(; '0' <= c && c <= '9'; c = getchar()) num = (num << 1) + (num << 3) + (c - '0'); if (neg) num = -num; return true; } int n, m, k; ll res = 0; ii c[N]; set<ar<int, 3>> rooms; vi profit; bool operator<(ar<int, 3> a, ar<int, 3> b) { return a[0] < b[0]; } int main() { scan(n), scan(m), scan(k); forw(i, 0, n) { ar<int, 3> room; scan(room[1]), scan(room[0]), room[2] = i; rooms.insert(room); } forw(i, 0, m) scan(c[i].fi), scan(c[i].se); sort(c, c + m, greater<ii>()); forw(i, 0, m) { auto it = rooms.lower_bound({c[i].se, 0, 0}); if (it == rooms.end()) continue; int cur = c[i].fi - (*it)[1]; if (cur > 0) { profit.pb(cur); rooms.erase(it); } } sort(all(profit), greater<int>()); forw(i, 0, min(k, sz(profit))) res += profit[i]; cout << res; }

Compilation message (stderr)

hot.cpp: In function 'int main()':
hot.cpp:24:12: warning: narrowing conversion of 'c[i].std::pair<long long int, long long int>::second' from 'long long int' to 'int' [-Wnarrowing]
   24 | #define se second
      |            ^
hot.cpp:76:43: note: in expansion of macro 'se'
   76 |         auto it = rooms.lower_bound({c[i].se, 0, 0});
      |                                           ^~
#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...