Submission #5162

# Submission time Handle Problem Language Result Execution time Memory
5162 2014-02-12T23:46:21 Z CodingIsHard 올림픽 피자 (tutorial5) C++
100 / 100
60 ms 1524 KB
#include "pizza.h"
#include <queue>
using namespace std;
  
int num , can;
int rest[8];
queue<int> p[256];
  
void Init() {}
  
void process(int pizza)
{
    Bake(p[pizza].front());
    p[pizza].pop();
    for(int i = 0;i < 8;i++)
        if(pizza & (1 << i))
            if(--rest[i] == 0)
                can ^= 1 << i;
}
  
void Order(int N, int *A)
{
    int pizza = 0;
    for(int i = 0;i < N;i++)
        pizza |= 1 << A[i];
      
    p[pizza].push(num++);
    if((pizza & can) == pizza)
        process(pizza);
}
  
void Delivery(int I)
{
    if(++rest[I] == 1)
    {
        can |= 1 << I;
  
        int iMin = -1;
        for(int i = can;i > 0;i = (i - 1) & can)
        {
            if(!p[i].empty() && (iMin == -1 || p[i].front() < p[iMin].front()))
                iMin = i;
        }
          
        if(iMin != -1)
            process(iMin);
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1392 KB Output is correct
2 Correct 0 ms 1392 KB Output is correct
3 Correct 0 ms 1392 KB Output is correct
4 Correct 0 ms 1392 KB Output is correct
5 Correct 0 ms 1392 KB Output is correct
6 Correct 0 ms 1392 KB Output is correct
7 Correct 0 ms 1392 KB Output is correct
8 Correct 0 ms 1392 KB Output is correct
9 Correct 0 ms 1392 KB Output is correct
10 Correct 0 ms 1392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1392 KB Output is correct
2 Correct 0 ms 1392 KB Output is correct
3 Correct 0 ms 1392 KB Output is correct
4 Correct 0 ms 1392 KB Output is correct
5 Correct 0 ms 1392 KB Output is correct
6 Correct 0 ms 1392 KB Output is correct
7 Correct 0 ms 1392 KB Output is correct
8 Correct 0 ms 1392 KB Output is correct
9 Correct 0 ms 1392 KB Output is correct
10 Correct 0 ms 1392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 1392 KB Output is correct
2 Correct 44 ms 1392 KB Output is correct
3 Correct 44 ms 1392 KB Output is correct
4 Correct 48 ms 1392 KB Output is correct
5 Correct 52 ms 1524 KB Output is correct
6 Correct 48 ms 1524 KB Output is correct
7 Correct 32 ms 1392 KB Output is correct
8 Correct 52 ms 1524 KB Output is correct
9 Correct 48 ms 1392 KB Output is correct
10 Correct 28 ms 1392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 1392 KB Output is correct
2 Correct 56 ms 1392 KB Output is correct
3 Correct 52 ms 1392 KB Output is correct
4 Correct 60 ms 1392 KB Output is correct
5 Correct 48 ms 1392 KB Output is correct
6 Correct 56 ms 1392 KB Output is correct
7 Correct 52 ms 1392 KB Output is correct
8 Correct 56 ms 1392 KB Output is correct
9 Correct 48 ms 1392 KB Output is correct
10 Correct 44 ms 1392 KB Output is correct