이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "pizza.h"
#include <queue>
using namespace std;
queue<int> Q[256];
int order_num;
int ingred[9];
int delivered;
void Init() {
order_num = 0;
}
void Order(int N, int *A) {
int ordering = 0;
for (int i = 0; i < N; i++) {
ordering |= (1 << A[i]);
}
if ((ordering & delivered) == ordering) {
Bake(order_num);
for (int i = 0; i < 8; i++) {
if (ordering & (1 << i)) {
ingred[i]--;
if (ingred[i] == 0) delivered ^= (1 << i);
}
}
}
else {
Q[ordering].push(order_num);
}
order_num++;
}
int check(int a)
{
for (int i = 0; i< 8; ++i) {
if (((a >> i) & 1) && (ingred[i] == 0)) return 0;
}
return 1;
}
void Delivery(int i) {
ingred[i]++;
if (ingred[i] == 1) {
delivered |= (1 << i);
}
int minIdx = -1;
int min = 99999;
for (int i = 0; i < 256; i++) {
if (!Q[i].empty() && check(i)) {
if (Q[i].front() < min) {
min = Q[i].front();
minIdx = i;
}
}
}
if (minIdx != -1) {
Bake(Q[minIdx].front());
Q[minIdx].pop();
for (int i = 0; i < 8; i++) {
if (minIdx & (1 << i)) {
ingred[i]--;
if (ingred[i] == 0) delivered ^= (1 << i);
}
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |