제출 #459

#제출 시각아이디문제언어결과실행 시간메모리
459tncks0121올림픽 피자 (tutorial5)C++98
100 / 100
84 ms1528 KiB
#include "pizza.h"
#include <queue>

using namespace std;

queue<int> Q[256];
int ORD;
int ing[10], ings;

void Init(){
	ORD = 0;
}

void check (){
	int state, f, i;
	while(1) {
		f = -1;
		for(state = ings; state > 0; state = (state - 1) & ings){
			if( !Q[state].empty() && (f < 0 || Q[f].front() > Q[state].front()) ) f = state;
		}
		if(f < 0) return; 
		Bake(Q[f].front()); Q[f].pop();
		for(i = 0; i < 8; i++) if(f & (1 << i)) {
			if(--ing[i] == 0) ings ^= (1 << i);
		}
	}
}

void Order (int N, int *A) {
	int a = 0, i;
	for(i = 0; i < N; i++) a |= (1 << A[i]);
	Q[a].push (ORD++);
	check();
}

void Delivery (int I){
	if(++ing[I] == 1) ings |= (1 << I);
	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...