This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "pizza.h"
#include <queue>
using namespace std;
queue<int> Q[256];
int ORD;
int ing[10], ings;
void Init(){
ORD = 0;
}
void check (){
int state, f, i;
while(1) {
f = -1;
for(state = ings; state > 0; state = (state - 1) & ings){
if( !Q[state].empty() && (f < 0 || Q[f].front() > Q[state].front()) ) f = state;
}
if(f < 0) return;
Bake(Q[f].front()); Q[f].pop();
for(i = 0; i < 8; i++) if(f & (1 << i)) {
if(--ing[i] == 0) ings ^= (1 << i);
}
}
}
void Order (int N, int *A) {
int a = 0, i;
for(i = 0; i < N; i++) a |= (1 << A[i]);
Q[a].push (ORD++);
check();
}
void Delivery (int I){
if(++ing[I] == 1) ings |= (1 << I);
check();
}
# | 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... |