# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
773093 |
2023-07-04T15:02:05 Z |
NK_ |
Hotel (CEOI11_hot) |
C++17 |
|
534 ms |
33804 KB |
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define f first
#define s second
#define mp make_pair
#define sz(x) int(x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
using ll = long long;
using pi = pair<int, int>;
template<class T> using V = vector<T>;
int d[15];
int read() {
char ch = getchar();
while (ch < '0' || ch > '9') {
ch = getchar();
}
int v = 0;
while ('0' <= ch && ch <= '9') {
v = v * 10 + (int) (ch - '0');
ch = getchar();
}
return v;
}
void write(ll x) {
int len = 0;
while (x > 0) {
d[len++] = x % 10;
x /= 10;
}
for (int i = len - 1; i >= 0; i--) {
putchar('0' + d[i]);
}
if (len == 0) {
putchar('0');
}
putchar('\n');
}
int main() {
cin.tie(0)->sync_with_stdio(0);
int N = read(), M = read(), O = read();
V<pi> A(N); for(auto& x : A) x.f = read(), x.s = read();
V<pi> B(M); for(auto& x : B) x.f = read(), x.s = read();
sort(all(A));
sort(rall(B));
set<pi> S; for(int i = 0; i < N; i++) S.insert(mp(A[i].s, i));
V<int> P;
for(int i = 0; i < M; i++) {
auto it = S.lower_bound(mp(B[i].s, -1));
if (it == end(S)) continue;
int j = (*it).s;
// cout << i << " " << j << endl;
P.push_back(B[i].f - A[j].f);
S.erase(it);
}
sort(rall(P));
ll ans = 0;
for(int i = 0; i < O; i++) {
if (P[i] <= 0) break;
ans += P[i];
}
write(ans);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
3180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
5240 KB |
Output is correct |
2 |
Correct |
33 ms |
4856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
171 ms |
13900 KB |
Output is correct |
2 |
Correct |
66 ms |
7988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
307 ms |
27476 KB |
Output is correct |
2 |
Correct |
473 ms |
27508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
341 ms |
33796 KB |
Output is correct |
2 |
Correct |
392 ms |
33804 KB |
Output is correct |
3 |
Correct |
534 ms |
33788 KB |
Output is correct |