# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
764600 | lorenzoferrari | Garage (IOI09_garage) | C++17 | 2 ms | 340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
using LL = long long;
int main() {
int n; cin >> n;
int m; cin >> m;
vector<int> r(n), w(m);
for (int& i : r) cin >> i;
for (int& i : w) cin >> i;
vector<int> p(m, -1);
priority_queue<int, vector<int>, greater<int>> Q;
for (int i = 0; i < n; ++i) {
Q.push(i);
}
queue<int> q;
for (int i = 0; i < 2*m; ++i) {
int c; cin >> c;;
if (c > 0) {
if (Q.empty()) {
q.push(c-1);
} else {
p[c-1] = Q.top();
Q.pop();
}
} else {
Q.push(p[-c-1]);
if (!q.empty()) {
p[q.front()] = Q.top();
Q.pop();
q.pop();
}
}
}
int ans = 0;
for (int i = 0; i < m; ++i) {
ans += r[p[i]] * w[i];
}
cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |