답안 #29948

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
29948 2017-07-21T11:20:58 Z boh7978 올림픽 피자 (tutorial5) C++14
20 / 100
63 ms 5804 KB
#include "pizza.h"
#define SIZE 100005
int order_num;
int elm[9];
typedef struct myd {
	int order_num;
	int n;
	int A[10];
};
int cnt;
myd cust[SIZE];


void Init() {

	order_num = 0;
	cnt = 0;
	for (int i = 0; i < 10; i++) {
		elm[i] = 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 {
		cust[cnt].order_num = order_num;
		cust[cnt].n = N;
		for (int i = 0; i < N; i++) {
			cust[cnt].A[i] = A[i];
		}
		cnt++;
	}
	order_num++;
}

void Delivery(int I) {
	elm[I]++;

	for (int c = 0; c < cnt; c++) {
		bool ready = true;

		for (int i = 0; i < cust[c].n; i++) {
			if (elm[cust[c].A[i]] == 0) { ready = false; break; }
		}

		if (ready) {
			for (int i = 0; i < cust[c].n; i++) {
				elm[cust[c].A[i]]--;
			}
			cust[c].order_num = 0;
			cust[c].n = 0;
			cnt--;
			Bake(c);
			break;
		}
	}

}

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:9:1: warning: 'typedef' was ignored in this declaration
 };
 ^
tutorial5.cpp: In function 'void Init()':
tutorial5.cpp:19:13: warning: iteration 9u invokes undefined behavior [-Waggressive-loop-optimizations]
   elm[i] = 0;
             ^
tutorial5.cpp:18:20: note: containing loop
  for (int i = 0; i < 10; i++) {
                    ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 5804 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 5804 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 5804 KB Output is correct
2 Correct 53 ms 5804 KB Output is correct
3 Correct 43 ms 5804 KB Output is correct
4 Correct 33 ms 5804 KB Output is correct
5 Correct 43 ms 5804 KB Output is correct
6 Correct 53 ms 5804 KB Output is correct
7 Correct 46 ms 5804 KB Output is correct
8 Correct 43 ms 5804 KB Output is correct
9 Correct 49 ms 5804 KB Output is correct
10 Correct 43 ms 5804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 63 ms 5804 KB Output isn't correct
2 Halted 0 ms 0 KB -