Submission #5296

#TimeUsernameProblemLanguageResultExecution timeMemory
5296baneling100올림픽 피자 (tutorial5)C++98
100 / 100
80 ms1528 KiB
#include <queue> #include "pizza.h" #define inf 0x7fffffff using namespace std; queue <int> q[256]; int order_num, a[8], curr; void Init() { order_num=curr=0; } void if_ok(void) { int i, mmin=inf, v=0, cnt, x; for(i=curr ; i>0 ; i=(i-1)&curr) { if(!q[i].empty()) if(mmin>q[i].front()) { mmin=q[i].front(); v=i; } } if(v) { x=q[v].front(); Bake(x); x=v; i=1; cnt=0; while(i<=x) { if(i&x) { a[cnt]--; if(a[cnt]==0) curr-=i; } i=i<<1; cnt++; } q[v].pop(); } } void Order(int N, int *A) { int i, x=0; for(i=0 ; i<N ; i++) x+=1<<A[i]; q[x].push(order_num++); if_ok(); } void Delivery(int I) { if(a[I]==0) curr+=1<<I; a[I]++; if_ok(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...