답안 #31863

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
31863 2017-09-11T08:01:36 Z minhtung0404 Brunhilda’s Birthday (BOI13_brunhilda) C++14
100 / 100
436 ms 80532 KB
#include<bits/stdc++.h>
const int N = 1e5 + 5;
const int M = 1e7 + 5;
const int inf = 1e9;
using namespace std;

int n, q, p[N], m, prime[M], ans[M], cnt = 1, ct;

int main(){
    scanf("%d%d", &n, &q);
    for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
    for (int i = 1; i <= n; i++){
        for (int j = 0; j < M; j+=p[i]) prime[j] = max(prime[j], p[i]);
    }
    ans[0] = 1;
    while(ct < M){
        if (ans[ct] == 0) break;
        while(cnt < ct + prime[ct] && cnt < M) ans[cnt] = ans[ct] + 1, cnt++;
        ct++;
    }
    while(q--){
        scanf("%d", &m);
        if (ans[m] == 0) printf("oo\n");
        else printf("%d\n", ans[m]-1);
    }
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:10:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &q);
                          ^
brunhilda.cpp:11:52: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
                                                    ^
brunhilda.cpp:22:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &m);
                        ^
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 80532 KB Output is correct
2 Correct 116 ms 80532 KB Output is correct
3 Correct 43 ms 80532 KB Output is correct
4 Correct 59 ms 80532 KB Output is correct
5 Correct 79 ms 80532 KB Output is correct
6 Correct 23 ms 80532 KB Output is correct
7 Correct 43 ms 80532 KB Output is correct
8 Correct 33 ms 80532 KB Output is correct
9 Correct 136 ms 80532 KB Output is correct
10 Correct 133 ms 80532 KB Output is correct
11 Correct 113 ms 80532 KB Output is correct
12 Correct 56 ms 80532 KB Output is correct
13 Correct 259 ms 80532 KB Output is correct
14 Correct 273 ms 80532 KB Output is correct
15 Correct 96 ms 80532 KB Output is correct
16 Correct 99 ms 80532 KB Output is correct
17 Correct 89 ms 80532 KB Output is correct
18 Correct 49 ms 80532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 69 ms 80532 KB Output is correct
2 Correct 106 ms 80532 KB Output is correct
3 Correct 363 ms 80532 KB Output is correct
4 Correct 119 ms 80532 KB Output is correct
5 Correct 229 ms 80532 KB Output is correct
6 Correct 83 ms 80532 KB Output is correct
7 Correct 76 ms 80532 KB Output is correct
8 Correct 119 ms 80532 KB Output is correct
9 Correct 259 ms 80532 KB Output is correct
10 Correct 379 ms 80532 KB Output is correct
11 Correct 363 ms 80532 KB Output is correct
12 Correct 166 ms 80532 KB Output is correct
13 Correct 53 ms 80532 KB Output is correct
14 Correct 116 ms 80532 KB Output is correct
15 Correct 279 ms 80532 KB Output is correct
16 Correct 89 ms 80532 KB Output is correct
17 Correct 306 ms 80532 KB Output is correct
18 Correct 263 ms 80532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 279 ms 80532 KB Output is correct
2 Correct 339 ms 80532 KB Output is correct
3 Correct 426 ms 80532 KB Output is correct
4 Correct 209 ms 80532 KB Output is correct
5 Correct 136 ms 80532 KB Output is correct
6 Correct 326 ms 80532 KB Output is correct
7 Correct 276 ms 80532 KB Output is correct
8 Correct 299 ms 80532 KB Output is correct
9 Correct 276 ms 80532 KB Output is correct
10 Correct 219 ms 80532 KB Output is correct
11 Correct 179 ms 80532 KB Output is correct
12 Correct 249 ms 80532 KB Output is correct
13 Correct 383 ms 80532 KB Output is correct
14 Correct 176 ms 80532 KB Output is correct
15 Correct 279 ms 80532 KB Output is correct
16 Correct 286 ms 80532 KB Output is correct
17 Correct 263 ms 80532 KB Output is correct
18 Correct 369 ms 80532 KB Output is correct
19 Correct 76 ms 80532 KB Output is correct
20 Correct 306 ms 80532 KB Output is correct
21 Correct 223 ms 80532 KB Output is correct
22 Correct 436 ms 80532 KB Output is correct
23 Correct 183 ms 80532 KB Output is correct
24 Correct 99 ms 80532 KB Output is correct
25 Correct 269 ms 80532 KB Output is correct
26 Correct 219 ms 80532 KB Output is correct
27 Correct 403 ms 80532 KB Output is correct
28 Correct 99 ms 80532 KB Output is correct
29 Correct 356 ms 80532 KB Output is correct
30 Correct 403 ms 80532 KB Output is correct
31 Correct 146 ms 80532 KB Output is correct
32 Correct 186 ms 80532 KB Output is correct
33 Correct 76 ms 80532 KB Output is correct
34 Correct 273 ms 80532 KB Output is correct
35 Correct 143 ms 80532 KB Output is correct
36 Correct 386 ms 80532 KB Output is correct
37 Correct 123 ms 80532 KB Output is correct
38 Correct 353 ms 80532 KB Output is correct
39 Correct 146 ms 80532 KB Output is correct
40 Correct 243 ms 80532 KB Output is correct
41 Correct 206 ms 80532 KB Output is correct
42 Correct 359 ms 80532 KB Output is correct