# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
964225 | anango | Garage (IOI09_garage) | C++17 | 2 ms | 856 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>
#define int long long
using namespace std;
signed main() {
int n,m;
cin >> n >> m;
int total = 0;
vector<int> rates(n);
vector<int> parkedposcar(n,-1);
vector<int> parkedcarpos(m,-1);
vector<int> weights(m);
set<int> available;
for (int i=0; i<n; i++) {
available.insert(i);
}
for (int i=0; i<n; i++) {
int x;
cin >> x;
rates[i] = x;
}
for (int i=0; i<m; i++) {
int x;
cin >> x;
weights[i] = x;
}
queue<int> Q;
for (int e=0; e<2*m; e++) {
//cout << "doing" <<" " << e << endl;
int x;
cin >> x;
if (x>0) {
x--;
if (!available.size()) {
Q.push(x);
}
else {
int minpos = *available.begin();
available.erase(minpos);
parkedcarpos[x] = minpos;
parkedposcar[minpos] = x;
total+=rates[minpos]*weights[x];
}
}
else {
x=-x;
x--;
assert(parkedcarpos[x]!=-1);
available.insert(parkedcarpos[x]);
parkedcarpos[x] = -1;
}
}
cout << total << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |