# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1012072 | deera | Garage (IOI09_garage) | C++14 | 1 ms | 604 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
// freopen("2009/garage.txt", "r", stdin);
ll n, m;
cin >> n >> m;
vector<ll> places(n);
for (int i = 0; i < n; i++)
cin >> places[i];
vector<ll> weights(m);
for (int i = 0; i < m; i++)
cin >> weights[i];
ll total = 0;
queue<ll> waiting;
priority_queue<pair<ll, ll>> avail;
map<ll, ll> booked;
for (int i = 0; i < n; i++) {
avail.push({-places[i], i});
}
for (int i = 0; i < m*2; i++) {
ll car;
cin >> car;
if (car < 0) {
car = -car;
car--;
ll place = booked[car];
avail.push({-places[place], place});
} else {
car--;
waiting.push(car);
}
while (avail.size() != 0 && waiting.size() != 0) {
ll next = waiting.front();
waiting.pop();
ll weight = weights[next];
pair<ll, ll> spot = avail.top();
avail.pop();
ll rate = -spot.first;
total += rate * weight;
}
}
cout << total;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |