답안 #31851

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
31851 2017-09-11T07:40:46 Z minhtung0404 Brunhilda’s Birthday (BOI13_brunhilda) C++14
35.5556 / 100
413 ms 80692 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(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> q;
    for (int i = 1; i <= n; i++) cin >> p[i];
    sort(p+1, p+1+n);
    for (int i = 1; i <= n; i++){
        int z = p[i];
        for (int j = 0; j < M; j+=z){
            prime[j] = z;
        }
    }
    for (int i = 1; i < M; i++) ans[i] = -inf;
    while(ct < M){
        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 76 ms 80692 KB Output is correct
2 Correct 89 ms 80692 KB Output is correct
3 Correct 79 ms 80692 KB Output is correct
4 Runtime error 49 ms 80692 KB Execution killed because of forbidden syscall writev (20)
5 Correct 89 ms 80692 KB Output is correct
6 Correct 63 ms 80692 KB Output is correct
7 Correct 109 ms 80692 KB Output is correct
8 Correct 79 ms 80692 KB Output is correct
9 Correct 116 ms 80692 KB Output is correct
10 Correct 136 ms 80692 KB Output is correct
11 Correct 113 ms 80692 KB Output is correct
12 Correct 49 ms 80692 KB Output is correct
13 Correct 293 ms 80692 KB Output is correct
14 Runtime error 286 ms 80692 KB Execution killed because of forbidden syscall writev (20)
15 Correct 109 ms 80692 KB Output is correct
16 Correct 83 ms 80692 KB Output is correct
17 Runtime error 86 ms 80692 KB Execution killed because of forbidden syscall writev (20)
18 Runtime error 49 ms 80692 KB Execution killed because of forbidden syscall writev (20)
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 80692 KB Output is correct
2 Correct 116 ms 80692 KB Output is correct
3 Correct 346 ms 80692 KB Output is correct
4 Correct 119 ms 80692 KB Output is correct
5 Correct 226 ms 80692 KB Output is correct
6 Correct 93 ms 80692 KB Output is correct
7 Correct 73 ms 80692 KB Output is correct
8 Correct 113 ms 80692 KB Output is correct
9 Correct 289 ms 80692 KB Output is correct
10 Correct 379 ms 80692 KB Output is correct
11 Correct 389 ms 80692 KB Output is correct
12 Correct 173 ms 80692 KB Output is correct
13 Correct 63 ms 80692 KB Output is correct
14 Correct 119 ms 80692 KB Output is correct
15 Correct 296 ms 80692 KB Output is correct
16 Correct 106 ms 80692 KB Output is correct
17 Correct 303 ms 80692 KB Output is correct
18 Correct 306 ms 80692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 276 ms 80692 KB Execution killed because of forbidden syscall writev (20)
2 Runtime error 413 ms 80692 KB Execution killed because of forbidden syscall writev (20)
3 Runtime error 409 ms 80692 KB Execution killed because of forbidden syscall writev (20)
4 Runtime error 193 ms 80692 KB Execution killed because of forbidden syscall writev (20)
5 Runtime error 133 ms 80692 KB Execution killed because of forbidden syscall writev (20)
6 Runtime error 296 ms 80692 KB Execution killed because of forbidden syscall writev (20)
7 Runtime error 303 ms 80692 KB Execution killed because of forbidden syscall writev (20)
8 Runtime error 289 ms 80692 KB Execution killed because of forbidden syscall writev (20)
9 Runtime error 276 ms 80692 KB Execution killed because of forbidden syscall writev (20)
10 Runtime error 223 ms 80692 KB Execution killed because of forbidden syscall writev (20)
11 Runtime error 153 ms 80692 KB Execution killed because of forbidden syscall writev (20)
12 Runtime error 229 ms 80692 KB Execution killed because of forbidden syscall writev (20)
13 Runtime error 319 ms 80692 KB Execution killed because of forbidden syscall writev (20)
14 Runtime error 149 ms 80692 KB Execution killed because of forbidden syscall writev (20)
15 Runtime error 266 ms 80692 KB Execution killed because of forbidden syscall writev (20)
16 Runtime error 293 ms 80692 KB Execution killed because of forbidden syscall writev (20)
17 Runtime error 276 ms 80692 KB Execution killed because of forbidden syscall writev (20)
18 Runtime error 399 ms 80692 KB Execution killed because of forbidden syscall writev (20)
19 Runtime error 63 ms 80692 KB Execution killed because of forbidden syscall writev (20)
20 Runtime error 366 ms 80692 KB Execution killed because of forbidden syscall writev (20)
21 Runtime error 183 ms 80692 KB Execution killed because of forbidden syscall writev (20)
22 Runtime error 359 ms 80692 KB Execution killed because of forbidden syscall writev (20)
23 Runtime error 109 ms 80692 KB Execution killed because of forbidden syscall writev (20)
24 Runtime error 76 ms 80692 KB Execution killed because of forbidden syscall writev (20)
25 Runtime error 209 ms 80692 KB Execution killed because of forbidden syscall writev (20)
26 Runtime error 183 ms 80692 KB Execution killed because of forbidden syscall writev (20)
27 Runtime error 399 ms 80692 KB Execution killed because of forbidden syscall writev (20)
28 Runtime error 69 ms 80692 KB Execution killed because of forbidden syscall writev (20)
29 Runtime error 343 ms 80692 KB Execution killed because of forbidden syscall writev (20)
30 Runtime error 316 ms 80692 KB Execution killed because of forbidden syscall writev (20)
31 Runtime error 96 ms 80692 KB Execution killed because of forbidden syscall writev (20)
32 Runtime error 136 ms 80692 KB Execution killed because of forbidden syscall writev (20)
33 Runtime error 49 ms 80692 KB Execution killed because of forbidden syscall writev (20)
34 Runtime error 246 ms 80692 KB Execution killed because of forbidden syscall writev (20)
35 Runtime error 83 ms 80692 KB Execution killed because of forbidden syscall writev (20)
36 Runtime error 333 ms 80692 KB Execution killed because of forbidden syscall writev (20)
37 Runtime error 116 ms 80692 KB Execution killed because of forbidden syscall writev (20)
38 Runtime error 253 ms 80692 KB Execution killed because of forbidden syscall writev (20)
39 Runtime error 79 ms 80692 KB Execution killed because of forbidden syscall writev (20)
40 Runtime error 209 ms 80692 KB Execution killed because of forbidden syscall writev (20)
41 Runtime error 203 ms 80692 KB Execution killed because of forbidden syscall writev (20)
42 Runtime error 303 ms 80692 KB Execution killed because of forbidden syscall writev (20)