# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
544899 | wenqi | Hotel (CEOI11_hot) | C++17 | 449 ms | 30412 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// trans rights
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N, M, O;
int V[500069];
vector<pair<int, int>> rooms, customers;
vector<int> profits;
int getv(int i)
{
return i == V[i] ? i : V[i] = getv(V[i]);
}
int main(int argc, const char *argv[])
{
scanf("%d%d%d", &N, &M, &O);
for (int i = 0; i < N; i++)
{
int c, p;
scanf("%d%d", &c, &p);
rooms.push_back({p, c});
V[i] = i;
}
V[N] = N;
sort(rooms.begin(), rooms.end());
for (int i = 0; i < M; i++)
{
int v, d;
scanf("%d%d", &v, &d);
customers.push_back({v, d});
}
sort(customers.begin(), customers.end(), [](const pair<int, int>& a, const pair<int, int>& b){
return a.first > b.first;
});
for (auto &c : customers)
{
auto [v, d] = c;
int a = 0;
int b = N + 1;
while (b - a > 1)
{
int m = (a + b) / 2;
if (rooms[m - 1].first >= d)
b = m;
else
a = m;
}
int room = getv(a);
if (room >= N)
continue;
int potential = v - rooms[room].second;
profits.push_back(-potential);
V[room]++;
}
sort(profits.begin(), profits.end());
ll profit = 0;
for (int i = 0; i < min<int>(O, profits.size()); i++)
profit += max(0, -profits[i]);
printf("%lld\n", profit);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |