# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
156856 | socho | Garage (IOI09_garage) | C++14 | 3 ms | 504 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int occ[n];
memset(occ, 0, sizeof occ);
int coe[n];
for (int i=0; i<n; i++) {
cin >> coe[i];
}
int where[n];
for (int i=0; i<n; i++) {
where[i] = -1;
}
int wgt[m];
for (int i=0; i<m; i++) {
cin >> wgt[i];
}
int sm = 0;
queue<int> wait;
for (int i=0; i<2*m; i++) {
int nxt;
cin >> nxt;
bool inc = true;
if (nxt < 0) {
inc = false;
nxt = -nxt;
}
nxt--;
if (inc) {
wait.push(nxt);
}
else {
int at = where[nxt];
occ[at] = false;
}
for (int j=0; j<n && !wait.empty(); j++) {
if (!occ[j]) {
occ[j] = true;
int c = wait.front(); wait.pop();
sm += wgt[c] * coe[j];
where[c] = j;
}
}
}
cout << sm << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |