# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1079277 |
2024-08-28T12:37:10 Z |
vjudge1 |
Garage (IOI09_garage) |
C++17 |
|
2 ms |
348 KB |
#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 |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
2 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |