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"
void Init(){}
int cnt[8],q[1<<8][100010],s[1<<8],e[1<<8],st,m;
void Order(int n, int *a){
int i,t=0;
for(i=0;i<n;++i)t+=(1<<a[i]);
if((st&t)!=t)q[t][e[t]++]=m++;
else{
Bake(m++);
for(i=0;i<n;++i){
--cnt[a[i]];
if(!cnt[a[i]])st-=(1<<a[i]);
}
}
}
void Delivery(int x){
int i,k,l=1e6;
++cnt[x];
if(cnt[x]<2){
st+=(1<<x);
for(i=1;i<(1<<8);++i)if(i&(1<<x)){
if((st&i)!=i)continue;
if(s[i]<e[i]&&l>q[i][s[i]])k=i,l=q[i][s[i]];
}
if(l<1e6){
for(i=0;i<8;++i)if(k&(1<<i)){
--cnt[i];
if(!cnt[i])st-=(1<<i);
}
Bake(q[k][s[k]++]);
}
}
}
# | 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... |