제출 #973126

#제출 시각아이디문제언어결과실행 시간메모리
973126moikipoikiGarage (IOI09_garage)C++17
40 / 100
2 ms768 KiB
#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 timeMemoryGrader output
Fetching results...