Submission #561708

# Submission time Handle Problem Language Result Execution time Memory
561708 2022-05-13T11:48:35 Z Trisanu_Das Garage (IOI09_garage) C++17
100 / 100
2 ms 340 KB
//BRUH IMMA DEAD
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main(){
    ll n, m; cin >> n >> m;
    vector<ll> cost(n + 5), weight(m + 5), pos(m + 5, -1);
    for(int i = 1; i <= n; i++) cin >> cost[i];
    for(int i = 1; i <= m; i++) cin >> weight[i];

    priority_queue<ll, vector<ll>, greater<ll>> parkings;
    for(int i = 1; i <= n; i++) parkings.push(i);

    queue<ll> curr_car;
    ll ans = 0;

    for(int x = 1; x <= 2 * m; x++) {
        ll i; cin >> i;
        if (i > 0) curr_car.push(i);
        else {
            i = -i;
            parkings.push(pos[i]);
        }

        while (!curr_car.empty() && !parkings.empty()) {
            ll car = curr_car.front();
            curr_car.pop();

            ll parking = parkings.top();
            parkings.pop();

            pos[car] = parking;
            ans += weight[car] * cost[parking];
        }
    }

    cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 2 ms 308 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 2 ms 212 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 212 KB Output is correct