Submission #31885

# Submission time Handle Problem Language Result Execution time Memory
31885 2017-09-11T10:47:32 Z aome Brunhilda’s Birthday (BOI13_brunhilda) C++14
100 / 100
533 ms 80140 KB
#include <bits/stdc++.h>
using namespace std;

const int M = 10000005;
const int INF = 1e9;

int n, q;
int nxt[M], res[M];

int main() {
    scanf("%d %d", &n, &q);
    for (int i = 0; i < n; ++i) {
        int x; scanf("%d", &x);
        for (int j = 0; j < M; j += x) nxt[j] = max(nxt[j], x);
    }
    int cur = 0;
    for (int i = 1; i < M; ++i) {
        while (cur < i) {
            if (!nxt[cur] || cur + nxt[cur] <= i) cur++;
            else break;
        }
        if (cur == i) break;
        res[i] = res[cur] + 1;
    }
    while (q--) {
        int x; scanf("%d", &x);
        if (!res[x]) printf("oo\n");
        else printf("%d\n", res[x]);
    }
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:11:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &q);
                           ^
brunhilda.cpp:13:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int x; scanf("%d", &x);
                               ^
brunhilda.cpp:26:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int x; scanf("%d", &x);
                               ^
# Verdict Execution time Memory Grader output
1 Correct 26 ms 80140 KB Output is correct
2 Correct 103 ms 80140 KB Output is correct
3 Correct 46 ms 80140 KB Output is correct
4 Correct 73 ms 80140 KB Output is correct
5 Correct 123 ms 80140 KB Output is correct
6 Correct 13 ms 80140 KB Output is correct
7 Correct 33 ms 80140 KB Output is correct
8 Correct 53 ms 80140 KB Output is correct
9 Correct 159 ms 80140 KB Output is correct
10 Correct 156 ms 80140 KB Output is correct
11 Correct 149 ms 80140 KB Output is correct
12 Correct 66 ms 80140 KB Output is correct
13 Correct 289 ms 80140 KB Output is correct
14 Correct 283 ms 80140 KB Output is correct
15 Correct 133 ms 80140 KB Output is correct
16 Correct 103 ms 80140 KB Output is correct
17 Correct 126 ms 80140 KB Output is correct
18 Correct 63 ms 80140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 113 ms 80140 KB Output is correct
2 Correct 106 ms 80140 KB Output is correct
3 Correct 343 ms 80140 KB Output is correct
4 Correct 156 ms 80140 KB Output is correct
5 Correct 279 ms 80140 KB Output is correct
6 Correct 119 ms 80140 KB Output is correct
7 Correct 106 ms 80140 KB Output is correct
8 Correct 166 ms 80140 KB Output is correct
9 Correct 453 ms 80140 KB Output is correct
10 Correct 429 ms 80140 KB Output is correct
11 Correct 446 ms 80140 KB Output is correct
12 Correct 239 ms 80140 KB Output is correct
13 Correct 113 ms 80140 KB Output is correct
14 Correct 173 ms 80140 KB Output is correct
15 Correct 356 ms 80140 KB Output is correct
16 Correct 116 ms 80140 KB Output is correct
17 Correct 336 ms 80140 KB Output is correct
18 Correct 323 ms 80140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 313 ms 80140 KB Output is correct
2 Correct 503 ms 80140 KB Output is correct
3 Correct 436 ms 80140 KB Output is correct
4 Correct 279 ms 80140 KB Output is correct
5 Correct 193 ms 80140 KB Output is correct
6 Correct 363 ms 80140 KB Output is correct
7 Correct 319 ms 80140 KB Output is correct
8 Correct 363 ms 80140 KB Output is correct
9 Correct 333 ms 80140 KB Output is correct
10 Correct 283 ms 80140 KB Output is correct
11 Correct 233 ms 80140 KB Output is correct
12 Correct 296 ms 80140 KB Output is correct
13 Correct 426 ms 80140 KB Output is correct
14 Correct 203 ms 80140 KB Output is correct
15 Correct 333 ms 80140 KB Output is correct
16 Correct 383 ms 80140 KB Output is correct
17 Correct 339 ms 80140 KB Output is correct
18 Correct 466 ms 80140 KB Output is correct
19 Correct 106 ms 80140 KB Output is correct
20 Correct 533 ms 80140 KB Output is correct
21 Correct 239 ms 80140 KB Output is correct
22 Correct 526 ms 80140 KB Output is correct
23 Correct 249 ms 80140 KB Output is correct
24 Correct 169 ms 80140 KB Output is correct
25 Correct 289 ms 80140 KB Output is correct
26 Correct 259 ms 80140 KB Output is correct
27 Correct 463 ms 80140 KB Output is correct
28 Correct 146 ms 80140 KB Output is correct
29 Correct 443 ms 80140 KB Output is correct
30 Correct 436 ms 80140 KB Output is correct
31 Correct 206 ms 80140 KB Output is correct
32 Correct 226 ms 80140 KB Output is correct
33 Correct 106 ms 80140 KB Output is correct
34 Correct 349 ms 80140 KB Output is correct
35 Correct 166 ms 80140 KB Output is correct
36 Correct 376 ms 80140 KB Output is correct
37 Correct 169 ms 80140 KB Output is correct
38 Correct 359 ms 80140 KB Output is correct
39 Correct 189 ms 80140 KB Output is correct
40 Correct 256 ms 80140 KB Output is correct
41 Correct 239 ms 80140 KB Output is correct
42 Correct 356 ms 80140 KB Output is correct