# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
336886 | 2020-12-17T07:13:24 Z | seedkin | 올림픽 피자 (tutorial5) | C | 25 ms | 1132 KB |
#include "pizza.h" struct Order { int next; int prev; int need[8]; int needCnt; }; int order_num; int material[8]; struct Order order[100000]; int root = -1; int last = -1; int check(int need[8], int needCnt) { for(int i =0; i< needCnt; i++) { if(material[need[i]] == 0) return 0; } return 1; } void Init() { order_num = 0; root = -1; last = -1; for(int i = 0; i < 8; i++) { material[i] = 0; } } void Order(int N, int *A) { int r = check(A, N); if(r) { Bake(order_num); order_num++; for(int i =0; i < N; i++) { material[A[i]]--; } return; } order[order_num].needCnt = N; for(int i =0; i < N; i++) { order[order_num].need[i] = A[i]; } order[order_num].next = -1; order[order_num].prev = -1; if(root == -1) { root = order; last = order; order_num++; return; } // int cur = root; // int prev = -1 // while(cur != -1) { // prev = cur; // cur = order[cur].next; // } order[last].next = order_num; order[order_num].prev = last; last = order_num; order_num++; return; } void Delivery(int I) { material[I]++; if(root == -1) return; int cur = root; while(cur != -1) { int r = check(order[cur].need, order[cur].needCnt); if(r) { Bake(cur); for(int i =0; i < order[cur].needCnt; i++) { material[order[cur].need[i]]--; } if(cur == root) { root = order[cur].next; if( root != -1) order[root].prev = -1; cur = root; continue; } if ( cur == last) { last = order[cur].prev; if(last != -1) order[last].next = -1; break; } order[order[cur].prev].next = order[cur].next; order[order[cur].next].prev = order[cur].prev; } cur = order[cur].next; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 364 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 364 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 25 ms | 1132 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |