답안 #1055646

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1055646 2024-08-13T01:59:37 Z Braulinho Garage (IOI09_garage) C++14
30 / 100
0 ms 348 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);

    ll N, M;
    cin >> N >> M;

    vector<ll> rates(N + 1);
    vector<ll> weights(M + 1);
    vector<ll> parking(N + 1, 0);
    queue<ll> waitingQueue;

    for (int i = 1; i <= N; ++i) {
        cin >> rates[i];
    }

    for (int i = 1; i <= M; ++i) {
        cin >> weights[i];
    }

    stack<ll> freeSpaces;
    for (int i = N; i >= 1; --i) {
        freeSpaces.push(i);
    }

    ll 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;
            ll 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()) {
                ll nextCar = waitingQueue.front();
                waitingQueue.pop();
                freeSpaces.pop();
                parking[space] = nextCar;
                totalRevenue += weights[nextCar] * rates[space];
            }
        }
    }

    cout << totalRevenue << endl;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 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 344 KB Output isn't correct
13 Incorrect 0 ms 348 KB Output isn't correct
14 Incorrect 0 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