# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1079277 | vjudge1 | Garage (IOI09_garage) | C++17 | 2 ms | 348 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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... |