답안 #31861

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
31861 2017-09-11T07:57:02 Z minhtung0404 Brunhilda’s Birthday (BOI13_brunhilda) C++14
65.7143 / 100
653 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]);
    }
    for (int i = 1; i < M; i++) ans[i] = -inf;
    while(ct < M){
        if (ans[ct] < 0) break;
        while(cnt < ct + prime[ct] && cnt < M) ans[cnt] = ans[ct] + 1, cnt++;
        ct++;
    }
    while(q--){
        cin >> m;
        if (ans[m] <= 0) printf("oo\n");
        else printf("%d\n", ans[m]);
    }
}

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]);
                                                    ^
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 80532 KB Output is correct
2 Correct 99 ms 80532 KB Output is correct
3 Correct 49 ms 80532 KB Output is correct
4 Correct 96 ms 80532 KB Output is correct
5 Correct 103 ms 80532 KB Output is correct
6 Correct 33 ms 80532 KB Output is correct
7 Correct 49 ms 80532 KB Output is correct
8 Correct 49 ms 80532 KB Output is correct
9 Correct 116 ms 80532 KB Output is correct
10 Correct 133 ms 80532 KB Output is correct
11 Correct 133 ms 80532 KB Output is correct
12 Correct 59 ms 80532 KB Output is correct
13 Correct 279 ms 80532 KB Output is correct
14 Correct 319 ms 80532 KB Output is correct
15 Correct 93 ms 80532 KB Output is correct
16 Correct 93 ms 80532 KB Output is correct
17 Correct 136 ms 80532 KB Output is correct
18 Correct 73 ms 80532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 86 ms 80532 KB Output is correct
2 Correct 99 ms 80532 KB Output is correct
3 Correct 356 ms 80532 KB Output is correct
4 Correct 113 ms 80532 KB Output is correct
5 Correct 223 ms 80532 KB Output is correct
6 Correct 69 ms 80532 KB Output is correct
7 Correct 76 ms 80532 KB Output is correct
8 Correct 113 ms 80532 KB Output is correct
9 Correct 289 ms 80532 KB Output is correct
10 Correct 346 ms 80532 KB Output is correct
11 Correct 363 ms 80532 KB Output is correct
12 Correct 179 ms 80532 KB Output is correct
13 Correct 56 ms 80532 KB Output is correct
14 Correct 106 ms 80532 KB Output is correct
15 Correct 293 ms 80532 KB Output is correct
16 Correct 96 ms 80532 KB Output is correct
17 Correct 289 ms 80532 KB Output is correct
18 Correct 306 ms 80532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 459 ms 80532 KB Execution timed out (wall clock limit exceeded)
2 Correct 559 ms 80532 KB Output is correct
3 Correct 473 ms 80532 KB Output is correct
4 Runtime error 406 ms 80532 KB Execution timed out (wall clock limit exceeded)
5 Runtime error 279 ms 80532 KB Execution timed out (wall clock limit exceeded)
6 Runtime error 596 ms 80532 KB Execution timed out (wall clock limit exceeded)
7 Correct 433 ms 80532 KB Output is correct
8 Correct 333 ms 80532 KB Output is correct
9 Correct 419 ms 80532 KB Output is correct
10 Correct 283 ms 80532 KB Output is correct
11 Correct 199 ms 80532 KB Output is correct
12 Correct 309 ms 80532 KB Output is correct
13 Runtime error 536 ms 80532 KB Execution timed out (wall clock limit exceeded)
14 Runtime error 306 ms 80532 KB Execution timed out (wall clock limit exceeded)
15 Correct 269 ms 80532 KB Output is correct
16 Correct 326 ms 80532 KB Output is correct
17 Correct 333 ms 80532 KB Output is correct
18 Correct 479 ms 80532 KB Output is correct
19 Correct 196 ms 80532 KB Output is correct
20 Runtime error 583 ms 80532 KB Execution timed out (wall clock limit exceeded)
21 Runtime error 383 ms 80532 KB Execution timed out (wall clock limit exceeded)
22 Runtime error 589 ms 80532 KB Execution timed out (wall clock limit exceeded)
23 Runtime error 263 ms 80532 KB Execution timed out (wall clock limit exceeded)
24 Runtime error 273 ms 80532 KB Execution timed out (wall clock limit exceeded)
25 Correct 399 ms 80532 KB Output is correct
26 Runtime error 376 ms 80532 KB Execution timed out (wall clock limit exceeded)
27 Correct 653 ms 80532 KB Output is correct
28 Correct 236 ms 80532 KB Output is correct
29 Runtime error 526 ms 80532 KB Execution timed out (wall clock limit exceeded)
30 Runtime error 513 ms 80532 KB Execution timed out (wall clock limit exceeded)
31 Runtime error 276 ms 80532 KB Execution timed out (wall clock limit exceeded)
32 Runtime error 319 ms 80532 KB Execution timed out (wall clock limit exceeded)
33 Runtime error 226 ms 80532 KB Execution timed out (wall clock limit exceeded)
34 Correct 336 ms 80532 KB Output is correct
35 Runtime error 293 ms 80532 KB Execution timed out (wall clock limit exceeded)
36 Runtime error 523 ms 80532 KB Execution timed out (wall clock limit exceeded)
37 Runtime error 286 ms 80532 KB Execution timed out (wall clock limit exceeded)
38 Runtime error 526 ms 80532 KB Execution timed out (wall clock limit exceeded)
39 Runtime error 209 ms 80532 KB Execution timed out (wall clock limit exceeded)
40 Runtime error 416 ms 80532 KB Execution timed out (wall clock limit exceeded)
41 Runtime error 349 ms 80532 KB Execution timed out (wall clock limit exceeded)
42 Correct 546 ms 80532 KB Output is correct