Submission #222287

# Submission time Handle Problem Language Result Execution time Memory
222287 2020-04-13T02:21:28 Z lyc Brunhilda’s Birthday (BOI13_brunhilda) C++14
78.0952 / 100
292 ms 80248 KB
#include <bits/stdc++.h>
using namespace std;

#define SZ(x) (int)(x).size()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i, a, b) for (int i=a;i>=b;--i)

const int MX_M = 1e5+5;
const int MX_Q = 1e5+5;
const int MX_P = 1e7+5;
const int infty = 1e9;

int M, Q, P[MX_M];
int pi[MX_P], dp[MX_P];

using ii = pair<int, int>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> M >> Q;
    FOR(i,1,M){
        cin >> P[i];
        for (int j = P[i]; j < MX_P; j += P[i]) pi[j-1] = P[i]-1;
    }

    RFOR(i,MX_P-2,0) pi[i] = max(pi[i],pi[i+1]-1);
    dp[0] = 0;
    FOR(i,1,MX_P-1) {
        if (pi[i] == 0) dp[i] = infty;
        else dp[i] = dp[i-pi[i]]+1;
    }

    FOR(i,1,Q){
        int N; cin >> N;
        if (dp[N] == infty) cout << "oo" << '\n';
        else cout << dp[N] << '\n';
    }
}

# Verdict Execution time Memory Grader output
1 Incorrect 99 ms 78584 KB Output isn't correct
2 Correct 113 ms 78584 KB Output is correct
3 Correct 106 ms 78584 KB Output is correct
4 Correct 102 ms 78728 KB Output is correct
5 Correct 107 ms 78660 KB Output is correct
6 Incorrect 100 ms 78712 KB Output isn't correct
7 Correct 108 ms 78584 KB Output is correct
8 Correct 109 ms 78584 KB Output is correct
9 Correct 125 ms 78712 KB Output is correct
10 Correct 141 ms 78712 KB Output is correct
11 Correct 149 ms 78584 KB Output is correct
12 Correct 97 ms 78584 KB Output is correct
13 Correct 209 ms 78716 KB Output is correct
14 Correct 217 ms 78712 KB Output is correct
15 Correct 122 ms 78584 KB Output is correct
16 Correct 114 ms 78584 KB Output is correct
17 Correct 112 ms 78840 KB Output is correct
18 Correct 119 ms 78712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 115 ms 78712 KB Output is correct
2 Correct 127 ms 79224 KB Output is correct
3 Correct 255 ms 79224 KB Output is correct
4 Correct 126 ms 78712 KB Output is correct
5 Correct 191 ms 79096 KB Output is correct
6 Correct 114 ms 78584 KB Output is correct
7 Correct 113 ms 78712 KB Output is correct
8 Correct 126 ms 78584 KB Output is correct
9 Correct 214 ms 79108 KB Output is correct
10 Correct 266 ms 79100 KB Output is correct
11 Incorrect 241 ms 78972 KB Output isn't correct
12 Correct 152 ms 78584 KB Output is correct
13 Correct 105 ms 78612 KB Output is correct
14 Correct 129 ms 78712 KB Output is correct
15 Correct 212 ms 78968 KB Output is correct
16 Correct 129 ms 79224 KB Output is correct
17 Correct 211 ms 78584 KB Output is correct
18 Correct 228 ms 79224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 228 ms 79352 KB Output is correct
2 Correct 261 ms 79224 KB Output is correct
3 Correct 275 ms 79480 KB Output is correct
4 Incorrect 186 ms 79576 KB Output isn't correct
5 Incorrect 162 ms 79480 KB Output isn't correct
6 Correct 231 ms 79736 KB Output is correct
7 Correct 213 ms 79708 KB Output is correct
8 Correct 231 ms 79352 KB Output is correct
9 Correct 232 ms 79352 KB Output is correct
10 Correct 188 ms 78840 KB Output is correct
11 Incorrect 161 ms 78840 KB Output isn't correct
12 Correct 206 ms 78968 KB Output is correct
13 Correct 265 ms 79864 KB Output is correct
14 Correct 168 ms 79480 KB Output is correct
15 Incorrect 215 ms 78968 KB Output isn't correct
16 Correct 241 ms 79100 KB Output is correct
17 Correct 215 ms 79096 KB Output is correct
18 Correct 261 ms 79224 KB Output is correct
19 Incorrect 113 ms 78944 KB Output isn't correct
20 Correct 264 ms 79480 KB Output is correct
21 Incorrect 189 ms 79992 KB Output isn't correct
22 Correct 291 ms 80248 KB Output is correct
23 Correct 158 ms 79224 KB Output is correct
24 Correct 136 ms 79224 KB Output is correct
25 Correct 204 ms 79868 KB Output is correct
26 Incorrect 182 ms 79608 KB Output isn't correct
27 Correct 292 ms 79608 KB Output is correct
28 Incorrect 137 ms 79352 KB Output isn't correct
29 Correct 267 ms 80124 KB Output is correct
30 Correct 244 ms 79992 KB Output is correct
31 Correct 153 ms 79096 KB Output is correct
32 Incorrect 161 ms 79224 KB Output isn't correct
33 Incorrect 129 ms 79096 KB Output isn't correct
34 Correct 212 ms 79736 KB Output is correct
35 Incorrect 137 ms 79224 KB Output isn't correct
36 Correct 272 ms 79992 KB Output is correct
37 Incorrect 160 ms 79480 KB Output isn't correct
38 Correct 235 ms 79736 KB Output is correct
39 Incorrect 143 ms 79224 KB Output isn't correct
40 Correct 205 ms 79736 KB Output is correct
41 Correct 196 ms 79808 KB Output is correct
42 Correct 241 ms 79864 KB Output is correct