# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
973126 | moikipoiki | Garage (IOI09_garage) | C++17 | 2 ms | 768 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 <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 |
---|---|---|---|---|
Fetching results... |