# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
309190 | Temmie | Garage (IOI09_garage) | C++17 | 2 ms | 384 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>
int main() {
std::ios::sync_with_stdio(0); std::cin.tie(0);
int n, m; std::cin >> n >> m;
std::vector <int> r(n);
for (int& x : r) std::cin >> x;
std::vector <int> w(m);
for (int& x : w) std::cin >> x;
std::vector <int> park(n, 0);
int ans = 0;
std::queue <int> q;
for (int i = 0; i < m << 1; i++) {
int p; std::cin >> p;
if (p > 0) {
q.push(p);
} else {
for (int j = 0; j < n; j++) {
if (park[j] == -p) park[j] = 0;
}
}
while (q.size()) {
bool ok = false;
int now = q.front();
for (int j = 0; j < n; j++) {
if (!park[j]) {
ok = true;
park[j] = now;
q.pop();
ans += w[now - 1] * r[j];
break;
}
}
if (!ok) break;
}
}
std::cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |