# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
309190 | Temmie | Garage (IOI09_garage) | C++17 | 2 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |