# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
18573 | jjhstop | 올림픽 피자 (tutorial5) | C++98 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "pizza.h"
#include <queue>
int order_num;
queue<int> Q[256];
int ingred[9];
int delivered;
void Init() {
order_num = 0;
}
void check(void)
{
while (1) {
int chk = -1;
for (int i = delivered; i > 0; i--) {
if (!Q[i].empty() && (chk < 0 || Q[chk].front() > Q[i].front())) chk = i;
}
if (chk < 0) return;
Bake(Q[chk].front()); Q[chk].pop();
for (int i = 0; i < 8; i++) {
if (chk & (1 << i)) {
if (--ingred[i] == 0) delivered ^= (1 << i);
}
}
}
}
void Order(int N, int *A) {
int ordering = 0;
for (int i = 0; i < N; i++) {
ordering |= (1 << A[i]);
}
Q[ordering].push(order_num);
order_num++;
check();
}
void Delivery(int i) {
ingred[i]++;
if (ingred[i] == 1) {
delivered |= (1 << i);
}
check();
}