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 <cstring>
#include <utility>
#include "pizza.h"
using namespace std;
queue<int> orders[256];
int ingred[8];
int order_num;
void Init() {
memset(ingred, 0, sizeof(ingred));
for(int i = 0 ; i < 256; ++i)
queue<int>().swap(orders[i]);
order_num =0;
}
bool asdf(int ing)
{
bool succ= true;
for(int i = 0 ; i< 8; ++i)
{
if((ing >> i)&1)
{
if(!ingred[i])
{
succ = false;
break;
}
}
}
return succ;
}
void asdf2(int ing)
{
{
for(int i = 0 ; i< 8; ++i)
{
if((ing >> i)&1)
{
ingred[i]--;
}
}
}
}
void Order(int N, int *A) {
int ing = 0;
for(int i = 0; i < N; ++i)
{
ing |= 1<<A[i];
}
if(asdf(ing))
{
asdf2(ing);
Bake(order_num);
}
else
orders[ing].push(order_num);
order_num++;
}
void Delivery(int I) {
ingred[I]++;
int min_i=-1;
int min_order_num = 987654321;
for(int i = 0 ; i < 256; ++i)
{
if(!orders[i].empty() && asdf(i))
{
if(orders[i].front() < min_order_num)
{
min_order_num = orders[i].front();
min_i = i;
}
}
}
if(min_i != -1)
{
asdf2(min_i);
Bake(orders[min_i].front());
orders[min_i].pop();
}
}
# | 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... |