#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 = 1e5 + 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
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});
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
460 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
8 ms |
2252 KB |
Execution killed with signal 6 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
56 ms |
8360 KB |
Execution killed with signal 6 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
77 ms |
14276 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
191 ms |
34940 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
415 ms |
64312 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
502 ms |
76900 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |