#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> rates;
int revenue = 0;
for (int i = 0; i < n; i++) {
int rate;
cin >> rate;
rates.push_back(rate);
}
vector<int> weights;
for (int j = 0; j < m; j++) {
int weight;
cin >> weight;
weights.push_back(weight);
}
vector<int> cars;
for (int k = 0; k < 2*m; k++) {
int car;
cin >> car;
cars.push_back(car);
}
vector<int> parked;
for (int p = 0; p < n; p++) {
parked.push_back(0);
}
for (int h:cars) {
if ( h > 0) {
auto lot = find(parked.begin(), parked.end(), 0);
auto index = distance(parked.begin(), lot);
parked[index] = h;
int c_weight = weights[h-1];
revenue += rates[index]*c_weight;
} else {
auto lot = find(parked.begin(), parked.end(), abs(h));
auto index = distance(parked.begin(), lot);
parked[index] = 0;
}
}
cout << revenue << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
504 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Incorrect |
1 ms |
500 KB |
Output isn't correct |
9 |
Correct |
0 ms |
436 KB |
Output is correct |
10 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
11 |
Correct |
1 ms |
768 KB |
Output is correct |
12 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
13 |
Correct |
1 ms |
436 KB |
Output is correct |
14 |
Incorrect |
1 ms |
448 KB |
Output isn't correct |
15 |
Correct |
2 ms |
444 KB |
Output is correct |
16 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
17 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
18 |
Incorrect |
2 ms |
448 KB |
Output isn't correct |
19 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
20 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |