답안 #18577

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
18577 2016-02-09T14:17:20 Z jjhstop 올림픽 피자 (tutorial5) C++
20 / 100
74 ms 1364 KB
#include "pizza.h"
#include <queue>

using namespace std;

queue<int> Q[256];
int order_num;
int ingred[9];
int delivered;

void Init() {
  order_num = 0;

}

void process(void)
{
	while (1) {
		int chk = -1;
		for (int i = delivered; i > 0; i = (i - 1) & delivered) {
			if (!Q[i].empty() && (chk < 0 || Q[chk].front() > Q[i].front())) chk = i;
		}
		if (chk < 0) return;
		Bake(Q[chk].front()); 
		Q[chk].pop();
		for (int i = 0; i < 8; i++) {
			if (chk & (1 << i)) {
				ingred[i]--;
				if (ingred[i] == 0) delivered ^= (1 << i);
			}
		}
	}
}

void Order(int N, int *A) {
	int ordering = 0;
	for (int i = 0; i < N; i++) {
		ordering |= (1 << A[i]);
	}
	if ((ordering & delivered) == ordering) {
		Bake(order_num);
		for (int i = 0; i < 8; i++) {
			if (ordering & (1 << i)) {
				ingred[i]--;
				if (ingred[i] == 0) delivered ^= (1 << i);
			}
		}
	}
	order_num++;	
}

void Delivery(int i) {
	ingred[i]++;
	if (ingred[i] == 1) {
		delivered |= (1 << i);
	}
	process();
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 1364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 74 ms 1364 KB Output is correct
2 Correct 73 ms 1364 KB Output is correct
3 Correct 71 ms 1364 KB Output is correct
4 Correct 72 ms 1364 KB Output is correct
5 Correct 65 ms 1364 KB Output is correct
6 Correct 70 ms 1364 KB Output is correct
7 Correct 57 ms 1364 KB Output is correct
8 Correct 74 ms 1364 KB Output is correct
9 Correct 66 ms 1364 KB Output is correct
10 Correct 72 ms 1364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 58 ms 1364 KB Output isn't correct
2 Halted 0 ms 0 KB -