Submission #12892

#TimeUsernameProblemLanguageResultExecution timeMemory
12892gs13105올림픽 피자 (tutorial5)C++98
100 / 100
56 ms1392 KiB
#include "pizza.h" #include <queue> std::queue<int> q[256]; int num[8]; int s; int c; void Init() { } void Order(int n, int *a) { bool u=1; int i; for(i=0;i<n;i++) { if(!num[a[i]]) { u=0; break; } } if(u) { Bake(c); for(i=0;i<n;i++) { num[a[i]]--; if(!num[a[i]]) s^=(1<<a[i]); } } else { int r=0; for(i=0;i<n;i++) r|=(1<<a[i]); q[r].push(c); } c++; } void Delivery(int a) { if(!num[a]) s|=(1<<a); num[a]++; if(num[a]==1) { int m=100000,r,i; for(i=s;i>=1;i=(i-1)&s) { if(!(i&(1<<a))) continue; if(!q[i].empty()&&q[i].front()<m) { m=q[i].front(); r=i; } } if(m!=100000) { Bake(q[r].front()); q[r].pop(); for(i=0;i<8;i++) { if(r&(1<<i)) { num[i]--; if(!num[i]) s^=(1<<i); } } } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...