Submission #18486

#TimeUsernameProblemLanguageResultExecution timeMemory
18486eaststar올림픽 피자 (tutorial5)C++14
45 / 100
88 ms101096 KiB
#include "pizza.h" void Init(){} int cnt[8],q[1<<8][100010],s[1<<8],e[1<<8],m; void Order(int n, int *a){ int i,t=0; for(i=0;i<n;++i)if(!cnt[a[i]])break; if(i<n){ for(i=0;i<n;++i)t+=(1<<a[i]); q[t][e[t]++]=m++; } else{ Bake(m++); for(i=0;i<n;++i)--cnt[a[i]]; } } void Delivery(int x){ int i,j,k,m=1e3; ++cnt[x]; if(cnt[x]<2){ for(i=1;i<(1<<8);++i)if(i&(1<<x)){ for(j=0;j<8;++j)if(i&(1<<j)&&!cnt[j])break; if(j>7&&s[i]<e[i]&&m>q[i][s[i]])k=i,m=q[i][s[i]]; } if(m<1e3){ for(i=0;i<8;++i)if(k&(1<<i))--cnt[i]; Bake(q[k][s[k]++]); } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...