# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
685052 | acceptify | Garage (IOI09_garage) | C++17 | 2 ms | 348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int mxn = 105;
const int mxm = 2005;
int n, m, x, r[mxn], w[mxm], pos[mxm], res = 0;
set<int> ok;
queue<int> q;
int main(){
cin >> n >> m;
for (int i = 1; i <= n; i++) cin >> r[i], ok.insert(i);
for (int i = 1; i <= m; i++) cin >> w[i];
for (int i = 1; i <= m * 2; i++) {
cin >> x;
if (x > 0) {
if (ok.empty()) q.push(x);
else {
pos[x] = *ok.begin();
ok.erase(ok.begin());
}
} else {
x = -x;
ok.insert(pos[x]);
if (!q.empty()) {
pos[q.front()] = *ok.begin();
ok.erase(ok.begin());
q.pop();
}
}
}
for (int i = 1; i <= m; i++) res += r[pos[i]] * w[i];
cout << res << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |