답안 #464758

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
464758 2021-08-14T00:14:08 Z JovanB Brunhilda’s Birthday (BOI13_brunhilda) C++17
92.0635 / 100
1000 ms 40752 KB
#pragma GCC optimize("Ofast")
#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 576 ms 39400 KB Output is correct
3 Correct 16 ms 1408 KB Output is correct
4 Correct 538 ms 39396 KB Output is correct
5 Correct 531 ms 39364 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 15 ms 1360 KB Output is correct
8 Correct 53 ms 3812 KB Output is correct
9 Correct 633 ms 39540 KB Output is correct
10 Correct 636 ms 39492 KB Output is correct
11 Correct 573 ms 39392 KB Output is correct
12 Correct 439 ms 39396 KB Output is correct
13 Correct 787 ms 39500 KB Output is correct
14 Correct 760 ms 39508 KB Output is correct
15 Correct 564 ms 39364 KB Output is correct
16 Correct 585 ms 39324 KB Output is correct
17 Correct 499 ms 39448 KB Output is correct
18 Correct 443 ms 39360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 517 ms 39508 KB Output is correct
2 Correct 446 ms 40228 KB Output is correct
3 Execution timed out 1075 ms 39760 KB Time limit exceeded
4 Correct 526 ms 39404 KB Output is correct
5 Correct 741 ms 39932 KB Output is correct
6 Correct 563 ms 39540 KB Output is correct
7 Correct 521 ms 39540 KB Output is correct
8 Correct 496 ms 39412 KB Output is correct
9 Correct 780 ms 39968 KB Output is correct
10 Execution timed out 1060 ms 39748 KB Time limit exceeded
11 Correct 922 ms 39700 KB Output is correct
12 Correct 632 ms 39440 KB Output is correct
13 Correct 484 ms 39360 KB Output is correct
14 Correct 569 ms 39448 KB Output is correct
15 Correct 815 ms 39880 KB Output is correct
16 Correct 449 ms 40184 KB Output is correct
17 Correct 765 ms 39364 KB Output is correct
18 Correct 988 ms 40344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 880 ms 40076 KB Output is correct
2 Correct 944 ms 40020 KB Output is correct
3 Correct 982 ms 40068 KB Output is correct
4 Correct 668 ms 39780 KB Output is correct
5 Correct 552 ms 40492 KB Output is correct
6 Correct 807 ms 39732 KB Output is correct
7 Correct 781 ms 40404 KB Output is correct
8 Correct 850 ms 40044 KB Output is correct
9 Correct 904 ms 39872 KB Output is correct
10 Correct 638 ms 39500 KB Output is correct
11 Correct 617 ms 39564 KB Output is correct
12 Correct 721 ms 39592 KB Output is correct
13 Correct 880 ms 39976 KB Output is correct
14 Correct 685 ms 39980 KB Output is correct
15 Correct 788 ms 39484 KB Output is correct
16 Correct 854 ms 39468 KB Output is correct
17 Correct 779 ms 39812 KB Output is correct
18 Correct 961 ms 40064 KB Output is correct
19 Correct 550 ms 39552 KB Output is correct
20 Correct 974 ms 40240 KB Output is correct
21 Correct 705 ms 39920 KB Output is correct
22 Execution timed out 1044 ms 40752 KB Time limit exceeded
23 Correct 574 ms 39880 KB Output is correct
24 Correct 485 ms 39640 KB Output is correct
25 Correct 657 ms 39772 KB Output is correct
26 Correct 663 ms 39836 KB Output is correct
27 Execution timed out 1055 ms 38120 KB Time limit exceeded
28 Correct 559 ms 39716 KB Output is correct
29 Execution timed out 1093 ms 40436 KB Time limit exceeded
30 Correct 825 ms 40224 KB Output is correct
31 Correct 597 ms 39708 KB Output is correct
32 Correct 571 ms 39980 KB Output is correct
33 Correct 502 ms 39748 KB Output is correct
34 Correct 817 ms 40440 KB Output is correct
35 Correct 548 ms 39720 KB Output is correct
36 Execution timed out 1032 ms 40500 KB Time limit exceeded
37 Correct 573 ms 40732 KB Output is correct
38 Correct 814 ms 39780 KB Output is correct
39 Correct 533 ms 39716 KB Output is correct
40 Correct 728 ms 39940 KB Output is correct
41 Correct 931 ms 40432 KB Output is correct
42 Correct 819 ms 39872 KB Output is correct