# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
511155 | 600Mihnea | Garage (IOI09_garage) | C++17 | 1 ms | 332 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 N = 2000 + 7;
int n;
int m;
int rate[N];
int who[N];
int weight[N];
int sol;
signed main() {
ios::sync_with_stdio(0); cin.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> rate[i];
}
for (int i = 1; i <= m; i++) {
cin >> weight[i];
}
queue<int> q;
for (int i = 1; i <= 2 * m; i++) {
int j;
cin >> j;
if (j > 0) {
q.push(j);
} else {
j *= -1;
for (int k = 1; k <= n; k++) {
if (who[k] == j) {
who[k] = 0;
}
}
}
for (int k = 1; k <= n && !q.empty(); k++) {
if (who[k] == 0) {
sol += weight[q.front()] * rate[k];
who[k] = q.front();
q.pop();
}
}
}
cout << sol << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |