답안 #14509

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
14509 2015-05-19T01:41:52 Z nosiar 올림픽 피자 (tutorial5) C++14
100 / 100
153 ms 1728 KB
#include <queue>
#include <cstring>
#include <utility>
#include "pizza.h"
using namespace std;
queue<int> orders[256];
int ingred[8];
int order_num;
void Init() {
  memset(ingred, 0, sizeof(ingred));
  for(int i = 0 ; i < 256; ++i)
	  queue<int>().swap(orders[i]);
  order_num =0;
}

bool asdf(int ing)
{
	bool succ= true;
	for(int i = 0 ; i< 8; ++i)
	{
		if((ing >> i)&1)
		{
			if(!ingred[i])
			{
				succ = false;
				break;
			}
		}
	}	
	return succ;
}
void asdf2(int ing)
{	
	{
		for(int i = 0 ; i< 8; ++i)
		{
			if((ing >> i)&1)
			{
				ingred[i]--;
			}
		}
	}
}

void Order(int N, int *A) {

int ing = 0; 
for(int i = 0; i < N; ++i)
{
	ing |= 1<<A[i];
}

if(asdf(ing))
{
	asdf2(ing);
	Bake(order_num);
}
else
	orders[ing].push(order_num);
order_num++;
}

void Delivery(int I) {
ingred[I]++;
int min_i=-1;
int min_order_num = 987654321;
for(int i = 0 ; i < 256; ++i)
{
		if(!orders[i].empty() && asdf(i))
		{
			if(orders[i].front() < min_order_num)
			{
				min_order_num = orders[i].front();
				min_i = i;
			}
		}
}
if(min_i != -1) 
{
	asdf2(min_i);
	Bake(orders[min_i].front());
	orders[min_i].pop();
}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1728 KB Output is correct
2 Correct 0 ms 1728 KB Output is correct
3 Correct 0 ms 1728 KB Output is correct
4 Correct 0 ms 1728 KB Output is correct
5 Correct 0 ms 1728 KB Output is correct
6 Correct 0 ms 1728 KB Output is correct
7 Correct 0 ms 1728 KB Output is correct
8 Correct 0 ms 1728 KB Output is correct
9 Correct 0 ms 1728 KB Output is correct
10 Correct 0 ms 1728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 1728 KB Output is correct
2 Correct 7 ms 1728 KB Output is correct
3 Correct 7 ms 1728 KB Output is correct
4 Correct 6 ms 1728 KB Output is correct
5 Correct 5 ms 1728 KB Output is correct
6 Correct 6 ms 1728 KB Output is correct
7 Correct 7 ms 1728 KB Output is correct
8 Correct 6 ms 1728 KB Output is correct
9 Correct 7 ms 1728 KB Output is correct
10 Correct 6 ms 1728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 1728 KB Output is correct
2 Correct 51 ms 1728 KB Output is correct
3 Correct 60 ms 1728 KB Output is correct
4 Correct 63 ms 1728 KB Output is correct
5 Correct 60 ms 1728 KB Output is correct
6 Correct 57 ms 1728 KB Output is correct
7 Correct 64 ms 1728 KB Output is correct
8 Correct 65 ms 1728 KB Output is correct
9 Correct 54 ms 1728 KB Output is correct
10 Correct 57 ms 1728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 148 ms 1728 KB Output is correct
2 Correct 145 ms 1728 KB Output is correct
3 Correct 135 ms 1728 KB Output is correct
4 Correct 146 ms 1728 KB Output is correct
5 Correct 152 ms 1728 KB Output is correct
6 Correct 153 ms 1728 KB Output is correct
7 Correct 148 ms 1728 KB Output is correct
8 Correct 143 ms 1728 KB Output is correct
9 Correct 141 ms 1728 KB Output is correct
10 Correct 141 ms 1728 KB Output is correct