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<vector>
using namespace std;
#define I 131072
static int order_num;
static int a[8];
static vector<int> b[256];
void Init() {
order_num = 0;
int i, j;
for(i=0; i<8; i++)
a[i] = 0;
for(i=0;i<256;i++)
b[i].clear();
}
void check()
{
int i, j, k;
for(i=j=0;i<8;i++)
if(a[i])
j += (1<<i);
int ti,tm;
ti = -1;
for(i=j;i;i=(i-1)&j)
{
if(b[i].size() == 0)continue;
if(ti<0 || tm>b[i][0])
{
ti = i;
tm = b[i][0];
}
}
if(ti<0)return;
Bake(tm);
for(i=0;i<8;i++)
if(ti&(1<<i))
a[i]--;
b[ti].erase(b[ti].begin());
}
void Order(int N, int *A) {
int i, j, k=0;
j=0;
for(i=0;i<N;i++)
k += (1<<A[i]);
for(i=0;i<8;i++)
if(a[i])
j += (1<<i);
b[k].push_back(order_num);
order_num++;
check();
}
void Delivery(int x) {
a[x]++;
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... |