Submission #482091

#TimeUsernameProblemLanguageResultExecution timeMemory
482091NeosHotel (CEOI11_hot)C++14
10 / 100
600 ms86220 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; int n, m, k, res; ii c[N]; set<ar<int, 3>> rooms; bool operator<(ar<int, 3> a, ar<int, 3> b) { return a[0] < b[0]; } int main() { fastIO; cin >> n >> m >> k; forw(i, 0, n) { ar<int, 3> room; cin >> room[1] >> room[0], room[2] = i; rooms.insert(room); } forw(i, 0, m) cin >> c[i].fi >> c[i].se; sort(c, c + m, greater<ii>()); vi profit; forw(i, 0, m) { auto it = rooms.lower_bound({c[i].se, 0, 0}); 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:59:43: note: in expansion of macro 'se'
   59 |         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...