Submission #14862

#TimeUsernameProblemLanguageResultExecution timeMemory
14862pichulia올림픽 피자 (tutorial5)C++98
100 / 100
87 ms1480 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...