답안 #464757

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
464757 2021-08-14T00:12:43 Z JovanB Brunhilda’s Birthday (BOI13_brunhilda) C++17
85.2381 / 100
1000 ms 42020 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;

const int N = 10000000;

int dp[N+5];
int tren;
queue <pair <int, int>> q[2];

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int m, qrs;
    cin >> m >> qrs;
    for(int i=1; i<=m; i++){
        int x;
        cin >> x;
        q[0].push({0, x});
    }
    for(int i=1; i<=N; i++){
        queue <int> divs;
        while(!q[0].empty()){
            int j, x;
            tie(j, x) = q[0].front();
            if(j + x < i) q[(tren != dp[j+x])].push({j + x, x});
            else if(j + x <= i) divs.push(x);
            else break;
            q[0].pop();
        }
        if(q[0].empty()) swap(q[0], q[1]), tren++;
        while(!q[0].empty()){
            int j, x;
            tie(j, x) = q[0].front();
            if(j + x < i) q[(tren != dp[j+x])].push({j + x, x});
            else if(j + x <= i) divs.push(x);
            else break;
            q[0].pop();
        }
        if(q[0].empty()) break;
        dp[i] = tren + 1;
        while(!divs.empty()) q[1].push({i, divs.front()}), divs.pop();
    }
    while(qrs--){
        int x;
        cin >> x;
        if(!dp[x]) cout << "oo\n";
        else cout << dp[x] << "\n";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 619 ms 39416 KB Output is correct
3 Correct 16 ms 1356 KB Output is correct
4 Correct 509 ms 39468 KB Output is correct
5 Correct 536 ms 39332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 19 ms 1348 KB Output is correct
8 Correct 60 ms 3956 KB Output is correct
9 Correct 684 ms 39344 KB Output is correct
10 Correct 705 ms 39364 KB Output is correct
11 Correct 662 ms 39428 KB Output is correct
12 Correct 495 ms 39364 KB Output is correct
13 Correct 817 ms 39456 KB Output is correct
14 Correct 831 ms 39464 KB Output is correct
15 Correct 618 ms 39416 KB Output is correct
16 Correct 654 ms 39452 KB Output is correct
17 Correct 527 ms 39408 KB Output is correct
18 Correct 538 ms 39424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 594 ms 39560 KB Output is correct
2 Correct 498 ms 40964 KB Output is correct
3 Execution timed out 1094 ms 37060 KB Time limit exceeded
4 Correct 593 ms 39472 KB Output is correct
5 Correct 815 ms 40272 KB Output is correct
6 Correct 591 ms 39456 KB Output is correct
7 Correct 573 ms 39584 KB Output is correct
8 Correct 568 ms 39416 KB Output is correct
9 Correct 958 ms 40612 KB Output is correct
10 Execution timed out 1097 ms 34184 KB Time limit exceeded
11 Correct 981 ms 40004 KB Output is correct
12 Correct 707 ms 39364 KB Output is correct
13 Correct 563 ms 39388 KB Output is correct
14 Correct 603 ms 39384 KB Output is correct
15 Correct 892 ms 40068 KB Output is correct
16 Correct 504 ms 40944 KB Output is correct
17 Correct 826 ms 39556 KB Output is correct
18 Execution timed out 1052 ms 41192 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 939 ms 40600 KB Output is correct
2 Execution timed out 1028 ms 40404 KB Time limit exceeded
3 Execution timed out 1024 ms 40864 KB Time limit exceeded
4 Correct 732 ms 40316 KB Output is correct
5 Correct 611 ms 42016 KB Output is correct
6 Correct 842 ms 40552 KB Output is correct
7 Correct 873 ms 41616 KB Output is correct
8 Correct 961 ms 40576 KB Output is correct
9 Correct 932 ms 40556 KB Output is correct
10 Correct 702 ms 39704 KB Output is correct
11 Correct 661 ms 39812 KB Output is correct
12 Correct 789 ms 39876 KB Output is correct
13 Correct 976 ms 40888 KB Output is correct
14 Correct 752 ms 40644 KB Output is correct
15 Correct 863 ms 39748 KB Output is correct
16 Correct 892 ms 39760 KB Output is correct
17 Correct 841 ms 40260 KB Output is correct
18 Execution timed out 1086 ms 40496 KB Time limit exceeded
19 Correct 613 ms 39716 KB Output is correct
20 Execution timed out 1046 ms 40116 KB Time limit exceeded
21 Correct 795 ms 40772 KB Output is correct
22 Execution timed out 1061 ms 41776 KB Time limit exceeded
23 Correct 659 ms 40924 KB Output is correct
24 Correct 600 ms 40500 KB Output is correct
25 Correct 729 ms 40488 KB Output is correct
26 Correct 742 ms 40324 KB Output is correct
27 Execution timed out 1085 ms 39380 KB Time limit exceeded
28 Correct 573 ms 40464 KB Output is correct
29 Execution timed out 1022 ms 42020 KB Time limit exceeded
30 Correct 877 ms 41452 KB Output is correct
31 Correct 660 ms 40324 KB Output is correct
32 Correct 662 ms 40480 KB Output is correct
33 Correct 630 ms 40396 KB Output is correct
34 Correct 871 ms 41544 KB Output is correct
35 Correct 602 ms 40540 KB Output is correct
36 Execution timed out 1070 ms 41948 KB Time limit exceeded
37 Correct 608 ms 42008 KB Output is correct
38 Correct 864 ms 40476 KB Output is correct
39 Correct 584 ms 40460 KB Output is correct
40 Correct 816 ms 40460 KB Output is correct
41 Correct 986 ms 41612 KB Output is correct
42 Correct 878 ms 40596 KB Output is correct