Submission #940337

# Submission time Handle Problem Language Result Execution time Memory
940337 2024-03-07T08:13:19 Z HappyCapybara Garage (IOI09_garage) C++17
40 / 100
2 ms 348 KB
#include<bits/stdc++.h>
using namespace std;

#define int long long

signed main(){
    int n, m; cin >> n >> m;
    vector<int> r(n);
    for (int i=0; i<n; i++) cin >> r[i];
    vector<int> w(m);
    for (int i=0; i<m; i++) cin >> w[i];
    vector<bool> t(n, false);
    vector<int> s(m);
    int res = 0;
    queue<int> q;
    for (int i=0; i<2*m; i++){
        int x;
        cin >> x;
        if (x < 0){
            x++;
            t[s[-x]] = false;
            if (!q.empty()){
                t[s[-x]] = true;
                s[q.front()] = s[-x];
                res += r[s[-x]] * w[q.front()];
                q.pop();
            }
            continue;
        }
        x--;
        int j = 0;
        while (t[j] && j<n) j++;
        if (j == n){
            q.push(j);
            continue;
        }
        t[j] = true;
        s[x] = j;
        res += r[j] * w[x];
    }
    cout << res << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Correct 1 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Correct 0 ms 348 KB Output is correct
10 Incorrect 1 ms 348 KB Output isn't correct
11 Correct 1 ms 348 KB Output is correct
12 Incorrect 1 ms 348 KB Output isn't correct
13 Correct 1 ms 348 KB Output is correct
14 Incorrect 1 ms 348 KB Output isn't correct
15 Correct 1 ms 348 KB Output is correct
16 Incorrect 1 ms 348 KB Output isn't correct
17 Incorrect 1 ms 348 KB Output isn't correct
18 Incorrect 2 ms 344 KB Output isn't correct
19 Incorrect 1 ms 348 KB Output isn't correct
20 Incorrect 1 ms 348 KB Output isn't correct