# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
512881 |
2022-01-16T19:18:45 Z |
blue |
Hotel (CEOI11_hot) |
C++17 |
|
394 ms |
35444 KB |
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
using ll = long long;
#define sz(x) int(x.size())
struct obj
{
int s;
int v;
int t;
};
bool operator < (obj A, obj B)
{
if(A.s != B.s) return A.s > B.s;
else return A.t > B.t;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m, o;
cin >> n >> m >> o;
vector<obj> a(m+n);
for(int i = 0; i < n; i++)
{
cin >> a[i].v >> a[i].s;
a[i].t = 1; //room
}
for(int j = n; j < n+m; j++)
{
cin >> a[j].v >> a[j].s;
a[j].t = 0; //customer
}
sort(a.begin(), a.end());
ll rooms_total = 0;
// int room_count = 0;
multiset<int> actual, fake;
for(obj x: a)
{
// cerr << "obj = " << x.v << ' ' << x.t << '\n';
if(x.t == 1)
{
rooms_total += x.v;
fake.insert(x.v);
}
else if(x.t == 0)
{
if(sz(actual) == o)
{
actual.insert(x.v);
actual.erase(*actual.begin());
}
else
{
actual.insert(x.v);
if(fake.empty() || *actual.begin() <= *fake.begin())
actual.erase(actual.begin());
else
fake.erase(fake.begin());
}
}
}
ll ans = -rooms_total;
for(int a: actual) ans += a;
for(int f: fake) ans += f;
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
892 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
32 ms |
3048 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
63 ms |
5116 KB |
Output is correct |
2 |
Incorrect |
62 ms |
4808 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
212 ms |
14344 KB |
Output is correct |
2 |
Incorrect |
117 ms |
8572 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
361 ms |
28380 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
394 ms |
35444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |