| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 685052 | acceptify | Garage (IOI09_garage) | C++17 | 2 ms | 348 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int mxn = 105;
const int mxm = 2005;
int n, m, x, r[mxn], w[mxm], pos[mxm], res = 0;
set<int> ok;
queue<int> q;
int main(){
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> r[i], ok.insert(i);
    for (int i = 1; i <= m; i++) cin >> w[i];
    for (int i = 1; i <= m * 2; i++) {
        cin >> x;
        if (x > 0) {
            if (ok.empty()) q.push(x);
            else {
                pos[x] = *ok.begin();
                ok.erase(ok.begin());
            }
        } else {
            x = -x;
            ok.insert(pos[x]);
            if (!q.empty()) {
                pos[q.front()] = *ok.begin();
                ok.erase(ok.begin());
                q.pop();
            }
        }
    }
    for (int i = 1; i <= m; i++) res += r[pos[i]] * w[i];
    cout << res << "\n";
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
