Submission #372896

# Submission time Handle Problem Language Result Execution time Memory
372896 2021-03-02T08:11:15 Z apostoldaniel854 Garage (IOI09_garage) C++14
45 / 100
2 ms 492 KB
#include <bits/stdc++.h>

using namespace std;
const int MAX_N = 100, MAX_M = 1000;
using ll = long long;

bool taken[1 + MAX_N];
bool wasted[1 + MAX_M];
int parked_at[1 + MAX_N];
int main () {
    ios::sync_with_stdio (false);
    cin.tie (0); cout.tie (0);
    int n, m;
    cin >> n >> m;
    vector <int> r (n + 1), w (m + 1);
    for (int i = 1; i <= n; i++)
        cin >> r[i];
    for (int i = 1; i <= m; i++)
        cin >> w[i];
    queue <int> car_line;
    ll ans = 0;
    for (int i = 1; i <= 2 * m; i++) {
        int t;
        cin >> t;
        if (t > 0)
            car_line.push (t);
        else {
            t = -t;
            wasted[t] = true;
            if (parked_at[t])
                taken[parked_at[t]] = false;
        }
        while (car_line.size () && wasted[car_line.front ()])
            car_line.pop ();
        if (car_line.size ()) {
            int space = 1;
            while (taken[space])
                space++;
            if (space <= n) {
                taken[space] = true;
                parked_at[car_line.front ()] = space;
                ans += w[car_line.front ()] * r[space];
                car_line.pop ();
            }
        }
    }
    cout << ans << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Runtime error 1 ms 492 KB Execution killed with signal 11
11 Runtime error 1 ms 492 KB Execution killed with signal 11
12 Runtime error 1 ms 492 KB Execution killed with signal 11
13 Runtime error 1 ms 492 KB Execution killed with signal 11
14 Runtime error 1 ms 492 KB Execution killed with signal 11
15 Runtime error 1 ms 492 KB Execution killed with signal 11
16 Runtime error 1 ms 492 KB Execution killed with signal 11
17 Runtime error 1 ms 492 KB Execution killed with signal 11
18 Runtime error 2 ms 492 KB Execution killed with signal 11
19 Runtime error 2 ms 492 KB Execution killed with signal 11
20 Runtime error 1 ms 492 KB Execution killed with signal 11