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 <queue>
#include "pizza.h"
#define inf 0x7fffffff
using namespace std;
queue <int> q[256];
int order_num, a[8], curr;
void Init()
{
order_num=curr=0;
}
void if_ok(void)
{
int i, mmin=inf, v=0, cnt, x;
for(i=curr ; i>0 ; i=(i-1)&curr)
{
if(!q[i].empty())
if(mmin>q[i].front())
{
mmin=q[i].front();
v=i;
}
}
if(v)
{
x=q[v].front();
Bake(x);
x=v;
i=1;
cnt=0;
while(i<=x)
{
if(i&x)
{
a[cnt]--;
if(a[cnt]==0)
curr-=i;
}
i=i<<1;
cnt++;
}
q[v].pop();
}
}
void Order(int N, int *A)
{
int i, x=0;
for(i=0 ; i<N ; i++)
x+=1<<A[i];
q[x].push(order_num++);
if_ok();
}
void Delivery(int I)
{
if(a[I]==0)
curr+=1<<I;
a[I]++;
if_ok();
}
# | 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... |