답안 #156534

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
156534 2019-10-06T11:05:34 Z combi1k1 Brunhilda’s Birthday (BOI13_brunhilda) C++14
100 / 100
384 ms 79612 KB
#include<bits/stdc++.h>

using namespace std;

const int   N   = 1e7 + 1;

int f[N];
int g[N];

int main()  {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int m;  cin >> m;
    int q;  cin >> q;

    for(int i = 1 ; i < N ; ++i)    f[i] = i;
    for(int i = 0 ; i < m ; ++i)    {
        int x;  cin >> x;
        for(int j = x ; j < N ; j += x)
            f[j - 1] = min(f[j - 1],j - x);
        f[N - 1] = min(f[N - 1],(N - 1) / x * x);
    }

    for(int i = N - 2 ; i ; --i)
        f[i] = min(f[i],f[i + 1]);

    for(int i = 1 ; i < N ; ++i)    {
        if (f[i] == i)
            g[i] = 1e9;
        else
            g[i] = g[f[i]] + 1;
    }

    //for(int i = 1 ; i < 10 ; ++i)
    //    cout << f[i] << " ";

    //cout << "\n";

    for(int i = 0 ; i < q ; ++i)    {
        int x;  cin >> x;
        if (g[x] >= 1e9)
            cout << "oo\n";
        else
            cout << g[x] << "\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 110 ms 78564 KB Output is correct
2 Correct 117 ms 78584 KB Output is correct
3 Correct 109 ms 78560 KB Output is correct
4 Correct 97 ms 78712 KB Output is correct
5 Correct 114 ms 78616 KB Output is correct
6 Correct 100 ms 78584 KB Output is correct
7 Correct 110 ms 78544 KB Output is correct
8 Correct 113 ms 78716 KB Output is correct
9 Correct 133 ms 78584 KB Output is correct
10 Correct 151 ms 78584 KB Output is correct
11 Correct 141 ms 78584 KB Output is correct
12 Correct 94 ms 78600 KB Output is correct
13 Correct 243 ms 78584 KB Output is correct
14 Correct 245 ms 78692 KB Output is correct
15 Correct 129 ms 78628 KB Output is correct
16 Correct 119 ms 78584 KB Output is correct
17 Correct 118 ms 78708 KB Output is correct
18 Correct 99 ms 78716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 115 ms 78652 KB Output is correct
2 Correct 138 ms 78916 KB Output is correct
3 Correct 315 ms 78588 KB Output is correct
4 Correct 140 ms 78584 KB Output is correct
5 Correct 223 ms 78560 KB Output is correct
6 Correct 118 ms 78584 KB Output is correct
7 Correct 114 ms 78748 KB Output is correct
8 Correct 139 ms 78712 KB Output is correct
9 Correct 248 ms 78688 KB Output is correct
10 Correct 303 ms 78564 KB Output is correct
11 Correct 298 ms 78584 KB Output is correct
12 Correct 175 ms 78712 KB Output is correct
13 Correct 107 ms 78564 KB Output is correct
14 Correct 138 ms 78556 KB Output is correct
15 Correct 261 ms 78584 KB Output is correct
16 Correct 135 ms 78584 KB Output is correct
17 Correct 257 ms 78584 KB Output is correct
18 Correct 256 ms 78584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 264 ms 79096 KB Output is correct
2 Correct 384 ms 79096 KB Output is correct
3 Correct 337 ms 79204 KB Output is correct
4 Correct 218 ms 79484 KB Output is correct
5 Correct 173 ms 79224 KB Output is correct
6 Correct 322 ms 79204 KB Output is correct
7 Correct 280 ms 79112 KB Output is correct
8 Correct 255 ms 79224 KB Output is correct
9 Correct 256 ms 79096 KB Output is correct
10 Correct 211 ms 78860 KB Output is correct
11 Correct 184 ms 78840 KB Output is correct
12 Correct 240 ms 78840 KB Output is correct
13 Correct 313 ms 79348 KB Output is correct
14 Correct 179 ms 79612 KB Output is correct
15 Correct 254 ms 78968 KB Output is correct
16 Correct 309 ms 78968 KB Output is correct
17 Correct 245 ms 78968 KB Output is correct
18 Correct 304 ms 78844 KB Output is correct
19 Correct 117 ms 78792 KB Output is correct
20 Correct 321 ms 79200 KB Output is correct
21 Correct 250 ms 79592 KB Output is correct
22 Correct 342 ms 79368 KB Output is correct
23 Correct 158 ms 79212 KB Output is correct
24 Correct 138 ms 79368 KB Output is correct
25 Correct 230 ms 79352 KB Output is correct
26 Correct 249 ms 79224 KB Output is correct
27 Correct 340 ms 79224 KB Output is correct
28 Correct 135 ms 79352 KB Output is correct
29 Correct 329 ms 79268 KB Output is correct
30 Correct 297 ms 79180 KB Output is correct
31 Correct 159 ms 79224 KB Output is correct
32 Correct 174 ms 79232 KB Output is correct
33 Correct 127 ms 79224 KB Output is correct
34 Correct 237 ms 78948 KB Output is correct
35 Correct 142 ms 79376 KB Output is correct
36 Correct 331 ms 79244 KB Output is correct
37 Correct 166 ms 79224 KB Output is correct
38 Correct 266 ms 79352 KB Output is correct
39 Correct 148 ms 79308 KB Output is correct
40 Correct 236 ms 79224 KB Output is correct
41 Correct 214 ms 79096 KB Output is correct
42 Correct 290 ms 79224 KB Output is correct