답안 #150938

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
150938 2019-09-01T12:21:57 Z dolphingarlic Brunhilda’s Birthday (BOI13_brunhilda) C++14
4.44444 / 100
1000 ms 81064 KB
#include <bits/stdc++.h>
#pragma GCC Optimize("O3")
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define MAXN 10000001
typedef long long ll;
using namespace std;

ll dp[MAXN];

int main() {
    iostream::sync_with_stdio(false);
    cin.tie(0);
    
    int n, q;
    cin >> n >> q;
    deque<pair<int, int>> dq;
    FOR(i, 0, n) {
        int k;
        cin >> k;
        dq.push_back({k, k});
    }

    dp[0] = 0;
    FOR(i, 1, MAXN) {
        dp[i] = INT_MAX;
        for (int j = 0; j < n && i == dq.front().first; j++) {
            int c, k;
            tie(c, k) = dq.front();
            dq.pop_front();
            while (c < dq.back().first) c += k;
            dq.push_back({c, k});
        }

        dp[i] = dp[i - (i % dq.front().second)] + 1;
    }

    FOR(i, 0, q) {
        int x;
        cin >> x;
        if (dp[x] >= INT_MAX) cout << "oo\n";
        else cout << dp[x] << '\n';
    }
    return 0;
}

Compilation message

brunhilda.cpp:2:0: warning: ignoring #pragma GCC Optimize [-Wunknown-pragmas]
 #pragma GCC Optimize("O3")
# 결과 실행 시간 메모리 Grader output
1 Correct 111 ms 78640 KB Output is correct
2 Incorrect 119 ms 78556 KB Output isn't correct
3 Incorrect 112 ms 78776 KB Output isn't correct
4 Incorrect 112 ms 78680 KB Output isn't correct
5 Incorrect 124 ms 78584 KB Output isn't correct
6 Correct 109 ms 78584 KB Output is correct
7 Incorrect 111 ms 78584 KB Output isn't correct
8 Incorrect 113 ms 78696 KB Output isn't correct
9 Incorrect 157 ms 78568 KB Output isn't correct
10 Incorrect 146 ms 78712 KB Output isn't correct
11 Incorrect 128 ms 78584 KB Output isn't correct
12 Correct 113 ms 78668 KB Output is correct
13 Incorrect 128 ms 78600 KB Output isn't correct
14 Correct 129 ms 78712 KB Output is correct
15 Incorrect 124 ms 78568 KB Output isn't correct
16 Incorrect 119 ms 78648 KB Output isn't correct
17 Incorrect 145 ms 78712 KB Output isn't correct
18 Incorrect 118 ms 78728 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 121 ms 78736 KB Output isn't correct
2 Execution timed out 1084 ms 57484 KB Time limit exceeded
3 Incorrect 751 ms 79664 KB Output isn't correct
4 Incorrect 120 ms 78656 KB Output isn't correct
5 Incorrect 380 ms 79404 KB Output isn't correct
6 Incorrect 116 ms 78584 KB Output isn't correct
7 Incorrect 120 ms 78840 KB Output isn't correct
8 Incorrect 115 ms 78692 KB Output isn't correct
9 Incorrect 431 ms 79764 KB Output isn't correct
10 Incorrect 753 ms 79664 KB Output isn't correct
11 Incorrect 350 ms 79184 KB Output isn't correct
12 Incorrect 121 ms 78684 KB Output isn't correct
13 Incorrect 115 ms 78780 KB Output isn't correct
14 Incorrect 120 ms 78756 KB Output isn't correct
15 Incorrect 310 ms 79172 KB Output isn't correct
16 Execution timed out 1055 ms 57464 KB Time limit exceeded
17 Incorrect 130 ms 78732 KB Output isn't correct
18 Execution timed out 1073 ms 49200 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Incorrect 419 ms 79804 KB Output isn't correct
2 Incorrect 393 ms 79736 KB Output isn't correct
3 Incorrect 419 ms 79964 KB Output isn't correct
4 Incorrect 167 ms 79608 KB Output isn't correct
5 Incorrect 265 ms 80968 KB Output isn't correct
6 Incorrect 161 ms 79608 KB Output isn't correct
7 Incorrect 539 ms 80724 KB Output isn't correct
8 Incorrect 420 ms 79996 KB Output isn't correct
9 Incorrect 423 ms 79816 KB Output isn't correct
10 Incorrect 164 ms 78968 KB Output isn't correct
11 Incorrect 148 ms 78900 KB Output isn't correct
12 Incorrect 182 ms 78996 KB Output isn't correct
13 Incorrect 270 ms 80184 KB Output isn't correct
14 Incorrect 150 ms 80120 KB Output isn't correct
15 Incorrect 181 ms 78968 KB Output isn't correct
16 Incorrect 200 ms 78904 KB Output isn't correct
17 Incorrect 263 ms 79448 KB Output isn't correct
18 Incorrect 379 ms 79656 KB Output isn't correct
19 Incorrect 131 ms 78952 KB Output isn't correct
20 Incorrect 418 ms 80056 KB Output isn't correct
21 Incorrect 146 ms 79996 KB Output isn't correct
22 Incorrect 921 ms 81028 KB Output isn't correct
23 Incorrect 182 ms 80272 KB Output isn't correct
24 Incorrect 144 ms 79736 KB Output isn't correct
25 Incorrect 155 ms 79848 KB Output isn't correct
26 Incorrect 169 ms 79736 KB Output isn't correct
27 Incorrect 971 ms 80652 KB Output isn't correct
28 Incorrect 137 ms 79864 KB Output isn't correct
29 Incorrect 555 ms 80988 KB Output isn't correct
30 Incorrect 326 ms 80796 KB Output isn't correct
31 Incorrect 146 ms 79612 KB Output isn't correct
32 Incorrect 152 ms 79720 KB Output isn't correct
33 Incorrect 145 ms 79640 KB Output isn't correct
34 Incorrect 545 ms 80612 KB Output isn't correct
35 Incorrect 139 ms 79832 KB Output isn't correct
36 Incorrect 818 ms 81064 KB Output isn't correct
37 Incorrect 267 ms 80888 KB Output isn't correct
38 Incorrect 161 ms 79740 KB Output isn't correct
39 Incorrect 148 ms 79848 KB Output isn't correct
40 Incorrect 163 ms 79864 KB Output isn't correct
41 Execution timed out 1047 ms 59536 KB Time limit exceeded
42 Incorrect 152 ms 79900 KB Output isn't correct