제출 #29948

#제출 시각아이디문제언어결과실행 시간메모리
29948boh7978올림픽 피자 (tutorial5)C++14
20 / 100
63 ms5804 KiB
#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;
		}
	}

}

컴파일 시 표준 에러 (stderr) 메시지

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++) {
                    ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...