# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
717662 | EntityPlantt | Garage (IOI09_garage) | C++14 | 1 ms | 340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <cstring>
#include <queue>
int main() {
int r = 0, m, n, i, x, j;
scanf("%d%d", &n, &m);
int rate[n + 5], weight[m + 5], parked[n + 5], where[m + 5], spacesLeft = n;
memset(parked, 0, sizeof(parked));
memset(where, 0, sizeof(where));
for (i = 0; i < n; i++) {
scanf("%d", rate + i);
}
for (i = 1; i <= m; i++) {
scanf("%d", weight + i);
}
std::queue <int> wait;
for (i = 0; i < 2 * m; i++) {
scanf("%d", &x);
if (x > 0) {
// Arrival
if (spacesLeft) {
for (j = 0; j < n; j++) {
if (!parked[j]) {
// Found parking place
parked[j] = x;
spacesLeft--;
r += rate[j] * weight[x];
// printf("Added %d to sum\n", rate[j] * weight[x]);
where[x] = j;
break;
}
}
}
else {
// Add to the queue
// printf("Added %d to queue\n", x);
wait.push(x);
}
}
else {
// Departure
x *= -1;
j = where[x];
parked[j] = 0;
spacesLeft++;
if (!wait.empty()) {
// Park a car from the queue
parked[j] = wait.front();
where[wait.front()] = j;
r += rate[j] * weight[wait.front()];
// printf("Added %d to sum\n", rate[j] * weight[wait.front()]);
spacesLeft--;
wait.pop();
}
}
}
printf("%d", r);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |