# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
703382 | finn__ | Garage (IOI09_garage) | C++17 | 2 ms | 340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main()
{
size_t n, m;
cin >> n >> m;
queue<unsigned> q_car;
priority_queue<pair<unsigned, unsigned>> q_lot;
for (size_t i = 0; i < n; i++)
{
unsigned s;
cin >> s;
q_lot.emplace(n - i, s);
}
vector<unsigned> weights(m);
vector<pair<unsigned, unsigned>> assigned_lot(m);
for (unsigned &x : weights)
cin >> x;
unsigned revenue = 0;
for (size_t i = 0; i < 2 * m; i++)
{
int j;
cin >> j;
if (j < 0)
{
if (!q_car.empty())
{
assigned_lot[q_car.front()] = assigned_lot[-j - 1];
revenue += weights[q_car.front()] * assigned_lot[-j - 1].second;
q_car.pop();
}
else
{
q_lot.push(assigned_lot[-j - 1]);
}
}
else
{
if (!q_lot.empty())
{
assigned_lot[j - 1] = q_lot.top();
revenue += weights[j - 1] * q_lot.top().second;
q_lot.pop();
}
else
{
q_car.push(j - 1);
}
}
}
cout << revenue << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |