답안 #16670

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
16670 2015-09-04T11:11:22 Z CodingBug 올림픽 피자 (tutorial5) C++
100 / 100
82 ms 1732 KB
#include "pizza.h"
#include <queue>
#define M 8

using namespace std;

int p,a[M],c;
queue<int> Q[1<<M];

void Init() {
    int i;
    p=0,c=-1;
    for(i=0;i<M;i++) a[i]=0;
    for(i=0;i<(1<<M);i++) while(!Q[i].empty()) Q[i].pop();
}

void Order(int N, int *A) {
    int ord=0,i;
    c++;
    for(i=0;i<N;i++) ord|=(1<<A[i]);
    if((p&ord)==ord){
        Bake(c);
        for(i=0;i<M;i++){
            if(ord&(1<<i)){
                a[i]--;
                if(!a[i]){
                    p-=(1<<i);
                }
            }
        }
    }
    else{
        Q[ord].push(c);
    }
}

void Delivery(int I) {
    a[I]++;
    if(a[I]==1){
        p|=(1<<I);
        int mn=c+1,v=-1,i;
        for(i=0;i<(1<<M);i++){
            if((p&i)==i && !Q[i].empty()){
                if(mn>Q[i].front()){
                    mn=Q[i].front();
                    v=i;
                }
            }
        }
        if(v!=-1){
            Bake(Q[v].front());
            for(i=0;i<M;i++){
                if(v&(1<<i)){
                    a[i]--;
                    if(!a[i]) p-=(1<<i);
                }
            }
            Q[v].pop();
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1732 KB Output is correct
2 Correct 0 ms 1732 KB Output is correct
3 Correct 0 ms 1732 KB Output is correct
4 Correct 0 ms 1732 KB Output is correct
5 Correct 0 ms 1732 KB Output is correct
6 Correct 0 ms 1732 KB Output is correct
7 Correct 0 ms 1732 KB Output is correct
8 Correct 0 ms 1732 KB Output is correct
9 Correct 0 ms 1732 KB Output is correct
10 Correct 0 ms 1732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1732 KB Output is correct
2 Correct 0 ms 1732 KB Output is correct
3 Correct 3 ms 1732 KB Output is correct
4 Correct 5 ms 1732 KB Output is correct
5 Correct 0 ms 1732 KB Output is correct
6 Correct 5 ms 1732 KB Output is correct
7 Correct 4 ms 1732 KB Output is correct
8 Correct 0 ms 1732 KB Output is correct
9 Correct 3 ms 1732 KB Output is correct
10 Correct 4 ms 1732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 1732 KB Output is correct
2 Correct 45 ms 1732 KB Output is correct
3 Correct 26 ms 1732 KB Output is correct
4 Correct 37 ms 1732 KB Output is correct
5 Correct 54 ms 1732 KB Output is correct
6 Correct 39 ms 1732 KB Output is correct
7 Correct 27 ms 1732 KB Output is correct
8 Correct 23 ms 1732 KB Output is correct
9 Correct 51 ms 1732 KB Output is correct
10 Correct 42 ms 1732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 69 ms 1732 KB Output is correct
2 Correct 72 ms 1732 KB Output is correct
3 Correct 68 ms 1732 KB Output is correct
4 Correct 80 ms 1732 KB Output is correct
5 Correct 82 ms 1732 KB Output is correct
6 Correct 69 ms 1732 KB Output is correct
7 Correct 66 ms 1732 KB Output is correct
8 Correct 79 ms 1732 KB Output is correct
9 Correct 71 ms 1732 KB Output is correct
10 Correct 72 ms 1732 KB Output is correct