# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1079277 | vjudge1 | Garage (IOI09_garage) | C++17 | 2 ms | 348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main() {
int n, m, money = 0;
cin >> n >> m;
vector<int> t(n);
vector<int> w(m);
vector<int> g(n, 0);
queue<int> wait;
for (int i = 0; i < n; i++) {
cin >> t[i];
}
for (int i = 0; i < m; i++) {
cin >> w[i];
}
for (int i = 0; i < m * 2; i++) {
int temp;
cin >> temp;
if (temp > 0) {
bool parked = false;
for (int j = 0; j < n; j++) {
if (g[j] == 0) {
g[j] = temp;
money += w[temp - 1] * t[j];
parked = true;
break;
}
}
if (!parked) wait.push(temp);
}
else {
int car = -temp;
for (int j = 0; j < n; j++) {
if (g[j] == car) {
g[j] = 0;
if (!wait.empty()) {
int nx = wait.front();
wait.pop();
g[j] = nx;
money += w[nx - 1] * t[j];
}
break;
}
}
}
}
cout << money;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |