#include "pizza.h"
#include <queue>
using namespace std;
int ing[8],have,ordernumber;
queue<int> orderlist[1<<8];
void Init(){
int i;
for (i=0;i<(1<<8);i++) while (!orderlist[i].empty()) orderlist[i].pop();
for (i=0;i<8;i++) ing[i] = 0;
have = ordernumber = 0;
}
void Order(int N, int *A) {
int what = 0, i;
for (i=0;i<N;i++) what += 1 << A[i];
if ((have & what) == what){
for (i=0;i<N;i++){
if (--ing[A[i]] == 0) have -= 1 << A[i];
}
Bake(ordernumber);
}
else orderlist[what].push(ordernumber);
ordernumber++;
}
void Delivery(int I) {
int i,num=ordernumber,x;
if (ing[I]++ == 0){
have += 1 << I;
for (i=have;i;i=have&(i-1)){
if (!orderlist[i].empty()){
if (num > orderlist[i].front()){
num = orderlist[i].front();
x = i;
}
}
}
if (num < ordernumber){
for (i=0;i<8;i++) if (x & (1 << i)){
if (--ing[i] == 0) have -= 1 << i;
}
Bake(num);
orderlist[x].pop();
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1096 KB |
Output is correct |
2 |
Correct |
0 ms |
1096 KB |
Output is correct |
3 |
Correct |
0 ms |
1096 KB |
Output is correct |
4 |
Correct |
0 ms |
1096 KB |
Output is correct |
5 |
Correct |
0 ms |
1096 KB |
Output is correct |
6 |
Correct |
0 ms |
1096 KB |
Output is correct |
7 |
Correct |
0 ms |
1096 KB |
Output is correct |
8 |
Correct |
0 ms |
1096 KB |
Output is correct |
9 |
Correct |
0 ms |
1096 KB |
Output is correct |
10 |
Correct |
0 ms |
1096 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1096 KB |
Output is correct |
2 |
Correct |
2 ms |
1096 KB |
Output is correct |
3 |
Correct |
2 ms |
1096 KB |
Output is correct |
4 |
Correct |
2 ms |
1096 KB |
Output is correct |
5 |
Correct |
2 ms |
1096 KB |
Output is correct |
6 |
Correct |
0 ms |
1096 KB |
Output is correct |
7 |
Correct |
2 ms |
1096 KB |
Output is correct |
8 |
Correct |
1 ms |
1096 KB |
Output is correct |
9 |
Correct |
2 ms |
1096 KB |
Output is correct |
10 |
Correct |
2 ms |
1096 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
44 ms |
1096 KB |
Output is correct |
2 |
Correct |
45 ms |
1096 KB |
Output is correct |
3 |
Correct |
41 ms |
1096 KB |
Output is correct |
4 |
Correct |
51 ms |
1096 KB |
Output is correct |
5 |
Correct |
52 ms |
1096 KB |
Output is correct |
6 |
Correct |
51 ms |
1096 KB |
Output is correct |
7 |
Correct |
38 ms |
1096 KB |
Output is correct |
8 |
Correct |
50 ms |
1096 KB |
Output is correct |
9 |
Correct |
46 ms |
1096 KB |
Output is correct |
10 |
Correct |
38 ms |
1096 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
55 ms |
1096 KB |
Output is correct |
2 |
Correct |
56 ms |
1096 KB |
Output is correct |
3 |
Correct |
53 ms |
1096 KB |
Output is correct |
4 |
Correct |
57 ms |
1096 KB |
Output is correct |
5 |
Correct |
55 ms |
1096 KB |
Output is correct |
6 |
Correct |
55 ms |
1096 KB |
Output is correct |
7 |
Correct |
56 ms |
1096 KB |
Output is correct |
8 |
Correct |
56 ms |
1096 KB |
Output is correct |
9 |
Correct |
57 ms |
1096 KB |
Output is correct |
10 |
Correct |
58 ms |
1096 KB |
Output is correct |