# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1055644 |
2024-08-13T01:58:11 Z |
Braulinho |
Garage (IOI09_garage) |
C++14 |
|
1 ms |
456 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.setf(ios::fixed);
cout.precision(10);
int N, M;
cin >> N >> M;
vector<int> rates(N + 1);
vector<int> weights(M + 1);
vector<int> parking(N + 1, 0);
queue<int> waitingQueue;
for (int i = 1; i <= N; ++i) {
cin >> rates[i];
}
for (int i = 1; i <= M; ++i) {
cin >> weights[i];
}
stack<int> freeSpaces;
for (int i = N; i >= 1; --i) {
freeSpaces.push(i);
}
int totalRevenue = 0;
for (int i = 0; i < 2 * M; ++i) {
int car;
cin >> car;
if (car > 0) {
if (!freeSpaces.empty()) {
int space = freeSpaces.top();
freeSpaces.pop();
parking[space] = car;
totalRevenue += weights[car] * rates[space];
} else {
waitingQueue.push(car);
}
} else {
car = -car;
int space = 0;
for (int j = 1; j <= N; ++j) {
if (parking[j] == car) {
space = j;
break;
}
}
parking[space] = 0;
freeSpaces.push(space);
if (!waitingQueue.empty()) {
int nextCar = waitingQueue.front();
waitingQueue.pop();
freeSpaces.pop();
parking[space] = nextCar;
totalRevenue += weights[nextCar] * rates[space];
}
}
}
cout << totalRevenue << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
456 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
8 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
9 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
12 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
13 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
14 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
15 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
16 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
17 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
18 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |