# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
973126 | moikipoiki | Garage (IOI09_garage) | C++17 | 2 ms | 768 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |