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;
int num , can;
int rest[8];
queue<int> p[256];
void Init() {}
void process(int pizza)
{
Bake(p[pizza].front());
p[pizza].pop();
for(int i = 0;i < 8;i++)
if(pizza & (1 << i))
if(--rest[i] == 0)
can ^= 1 << i;
}
void Order(int N, int *A)
{
int pizza = 0;
for(int i = 0;i < N;i++)
pizza |= 1 << A[i];
p[pizza].push(num++);
if((pizza & can) == pizza)
process(pizza);
}
void Delivery(int I)
{
if(++rest[I] == 1)
can |= 1 << I;
int iMin = -1;
for(int i = can;i > 0;i = (i - 1) & can)
{
if(!p[i].empty() && (iMin == -1 || p[i].front() < p[iMin].front()))
iMin = i;
}
if(iMin != -1)
process(iMin);
}
# | 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... |