# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
27423 | boh7978 | 올림픽 피자 (tutorial5) | C++14 | 1000 ms | 10808 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |