답안 #31859

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
31859 2017-09-11T07:51:55 Z minhtung0404 Brunhilda’s Birthday (BOI13_brunhilda) C++14
55.7143 / 100
619 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(){
    cin >> n >> q;
    for (int i = 1; i <= n; i++) cin >> 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) cout << "oo\n";
        else cout << ans[m] << "\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 80532 KB Output is correct
2 Correct 99 ms 80532 KB Output is correct
3 Correct 39 ms 80532 KB Output is correct
4 Correct 63 ms 80532 KB Output is correct
5 Correct 89 ms 80532 KB Output is correct
6 Correct 33 ms 80532 KB Output is correct
7 Correct 46 ms 80532 KB Output is correct
8 Correct 36 ms 80532 KB Output is correct
9 Correct 133 ms 80532 KB Output is correct
10 Correct 146 ms 80532 KB Output is correct
11 Correct 146 ms 80532 KB Output is correct
12 Correct 49 ms 80532 KB Output is correct
13 Correct 279 ms 80532 KB Output is correct
14 Correct 289 ms 80532 KB Output is correct
15 Correct 103 ms 80532 KB Output is correct
16 Correct 103 ms 80532 KB Output is correct
17 Correct 126 ms 80532 KB Output is correct
18 Correct 89 ms 80532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 86 ms 80532 KB Output is correct
2 Correct 123 ms 80532 KB Output is correct
3 Correct 406 ms 80532 KB Output is correct
4 Correct 123 ms 80532 KB Output is correct
5 Correct 263 ms 80532 KB Output is correct
6 Correct 96 ms 80532 KB Output is correct
7 Correct 86 ms 80532 KB Output is correct
8 Correct 106 ms 80532 KB Output is correct
9 Correct 309 ms 80532 KB Output is correct
10 Correct 416 ms 80532 KB Output is correct
11 Correct 359 ms 80532 KB Output is correct
12 Correct 173 ms 80532 KB Output is correct
13 Correct 63 ms 80532 KB Output is correct
14 Correct 126 ms 80532 KB Output is correct
15 Correct 313 ms 80532 KB Output is correct
16 Correct 129 ms 80532 KB Output is correct
17 Correct 299 ms 80532 KB Output is correct
18 Correct 303 ms 80532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 423 ms 80532 KB Execution timed out (wall clock limit exceeded)
2 Correct 463 ms 80532 KB Output is correct
3 Runtime error 573 ms 80532 KB Execution timed out (wall clock limit exceeded)
4 Runtime error 339 ms 80532 KB Execution timed out (wall clock limit exceeded)
5 Runtime error 316 ms 80532 KB Execution timed out (wall clock limit exceeded)
6 Runtime error 416 ms 80532 KB Execution timed out (wall clock limit exceeded)
7 Correct 399 ms 80532 KB Output is correct
8 Runtime error 473 ms 80532 KB Execution timed out (wall clock limit exceeded)
9 Runtime error 433 ms 80532 KB Execution timed out (wall clock limit exceeded)
10 Correct 296 ms 80532 KB Output is correct
11 Correct 279 ms 80532 KB Output is correct
12 Correct 299 ms 80532 KB Output is correct
13 Runtime error 456 ms 80532 KB Execution timed out (wall clock limit exceeded)
14 Runtime error 309 ms 80532 KB Execution timed out (wall clock limit exceeded)
15 Correct 419 ms 80532 KB Output is correct
16 Correct 499 ms 80532 KB Output is correct
17 Correct 363 ms 80532 KB Output is correct
18 Correct 563 ms 80532 KB Output is correct
19 Correct 109 ms 80532 KB Output is correct
20 Runtime error 586 ms 80532 KB Execution timed out (wall clock limit exceeded)
21 Runtime error 363 ms 80532 KB Execution timed out (wall clock limit exceeded)
22 Runtime error 619 ms 80532 KB Execution timed out (wall clock limit exceeded)
23 Runtime error 316 ms 80532 KB Execution timed out (wall clock limit exceeded)
24 Runtime error 219 ms 80532 KB Execution timed out (wall clock limit exceeded)
25 Runtime error 376 ms 80532 KB Execution timed out (wall clock limit exceeded)
26 Runtime error 319 ms 80532 KB Execution timed out (wall clock limit exceeded)
27 Runtime error 599 ms 80532 KB Execution timed out (wall clock limit exceeded)
28 Runtime error 223 ms 80532 KB Execution timed out (wall clock limit exceeded)
29 Runtime error 553 ms 80532 KB Execution timed out (wall clock limit exceeded)
30 Runtime error 459 ms 80532 KB Execution timed out (wall clock limit exceeded)
31 Runtime error 249 ms 80532 KB Execution timed out (wall clock limit exceeded)
32 Runtime error 323 ms 80532 KB Execution timed out (wall clock limit exceeded)
33 Runtime error 219 ms 80532 KB Execution timed out (wall clock limit exceeded)
34 Correct 319 ms 80532 KB Output is correct
35 Runtime error 243 ms 80532 KB Execution timed out (wall clock limit exceeded)
36 Runtime error 596 ms 80532 KB Execution timed out (wall clock limit exceeded)
37 Runtime error 289 ms 80532 KB Execution timed out (wall clock limit exceeded)
38 Runtime error 436 ms 80532 KB Execution timed out (wall clock limit exceeded)
39 Runtime error 269 ms 80532 KB Execution timed out (wall clock limit exceeded)
40 Runtime error 423 ms 80532 KB Execution timed out (wall clock limit exceeded)
41 Runtime error 379 ms 80532 KB Execution timed out (wall clock limit exceeded)
42 Runtime error 439 ms 80532 KB Execution timed out (wall clock limit exceeded)