답안 #27423

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
27423 2017-07-12T13:08:40 Z boh7978 올림픽 피자 (tutorial5) C++14
20 / 100
1000 ms 10808 KB
#include "pizza.h"
#include<malloc.h>

int order_num;
int elm[9];

typedef struct NODE {
	int id;
	int n;
	int topping[9];
	NODE* next;
};
NODE customer;
void Init() {

	order_num = 0;
	for (int i = 0; i < 9; i++) {
		elm[i] = 0;
	}
	customer.id = -1;
	customer.n = 0;
	customer.next = 0;
}

void Order(int N, int *A) {

	bool ready = true;
	for (int i = 0; i < N; i++) {
		if (elm[A[i]] == 0) { ready = false; break; }
	}
	if (ready) {
		Bake(order_num);
		for (int i = 0; i < N; i++) {
			elm[A[i]]--;
		}
	}
	else {
		NODE* nnode = new NODE;
		nnode->id = order_num;
		nnode->n = N;
		for (int i = 0; i < N; i++) {
			nnode->topping[i] = A[i];
		}
		nnode->next = customer.next;;
		customer.next = nnode;
		
	}
	order_num++;
}

void Delivery(int I) {
	elm[I]++;
	NODE* cur = new NODE;
	NODE* pre= new NODE;
	cur = &customer;
	pre = &customer;

	while (cur != 0) {
		if (cur->n != 0) {
			bool ready = true;
			for (int i = 0; i < cur->n; i++) {
				if (elm[cur->topping[i]] == 0) { ready = false; break; }
			}
			if (ready) {
				Bake(cur->id);
				for (int i = 0; i < cur->n; i++) {
					elm[cur->topping[i]]--;
				}
				pre->next = cur->next;
				break;
			}
		}
		pre = cur;
		cur = cur->next;
	}

}

Compilation message

grader.cpp: In function 'int main(int, char**)':
grader.cpp:65:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
tutorial5.cpp:13:1: warning: 'typedef' was ignored in this declaration
 };
 ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 1172 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 1700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 10412 KB Output is correct
2 Correct 53 ms 9884 KB Output is correct
3 Correct 46 ms 10544 KB Output is correct
4 Correct 56 ms 9884 KB Output is correct
5 Correct 59 ms 9620 KB Output is correct
6 Correct 46 ms 9620 KB Output is correct
7 Correct 49 ms 10676 KB Output is correct
8 Correct 53 ms 9620 KB Output is correct
9 Correct 43 ms 10016 KB Output is correct
10 Correct 39 ms 10808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1000 ms 5924 KB Execution timed out
2 Halted 0 ms 0 KB -