답안 #209935

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
209935 2020-03-16T02:26:59 Z dantoh000 Brunhilda’s Birthday (BOI13_brunhilda) C++14
100 / 100
332 ms 87800 KB
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
const int MAXN = 11000000;
int a[MAXN];
int ans[MAXN];
int main(){
    int n,q;
    scanf("%d%d",&n,&q);
    for (int i = 0; i < n; i++){
        int k;
        scanf("%d",&k);
        for (int j = k-1; j < MAXN; j+=k){
            a[j] = k-1;
        }
    }
    for (int i = MAXN-2; i >= 0; i--){
        a[i] = max(a[i],a[i+1]-1);
    }
    fill(ans,ans+MAXN,INF);
    ans[1] = 1;
    ans[0] = 0;
    for (int i = 2; i < MAXN; i++){
        if (a[i] == 0) ans[i] = INF;
        else ans[i] = min(ans[i],ans[i-a[i]]+1);
    }
    for (int i = 0; i < q; i++){
        int x;
        scanf("%d",&x);
        if (ans[x] == INF) printf("oo\n");
        else printf("%d\n",ans[x]);
    }
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&q);
     ~~~~~^~~~~~~~~~~~~~
brunhilda.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&k);
         ~~~~~^~~~~~~~~
brunhilda.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&x);
         ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 121 ms 86392 KB Output is correct
2 Correct 138 ms 86396 KB Output is correct
3 Correct 126 ms 86368 KB Output is correct
4 Correct 120 ms 86520 KB Output is correct
5 Correct 130 ms 86388 KB Output is correct
6 Correct 121 ms 86392 KB Output is correct
7 Correct 130 ms 86520 KB Output is correct
8 Correct 134 ms 86392 KB Output is correct
9 Correct 150 ms 86392 KB Output is correct
10 Correct 170 ms 86392 KB Output is correct
11 Correct 158 ms 86392 KB Output is correct
12 Correct 117 ms 86428 KB Output is correct
13 Correct 242 ms 86392 KB Output is correct
14 Correct 246 ms 86520 KB Output is correct
15 Correct 145 ms 86392 KB Output is correct
16 Correct 136 ms 86392 KB Output is correct
17 Correct 138 ms 86444 KB Output is correct
18 Correct 121 ms 86520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 136 ms 86520 KB Output is correct
2 Correct 150 ms 86520 KB Output is correct
3 Correct 289 ms 86564 KB Output is correct
4 Correct 148 ms 86392 KB Output is correct
5 Correct 222 ms 86520 KB Output is correct
6 Correct 138 ms 86516 KB Output is correct
7 Correct 131 ms 86520 KB Output is correct
8 Correct 145 ms 86396 KB Output is correct
9 Correct 251 ms 86520 KB Output is correct
10 Correct 292 ms 86520 KB Output is correct
11 Correct 276 ms 86520 KB Output is correct
12 Correct 179 ms 86392 KB Output is correct
13 Correct 125 ms 86392 KB Output is correct
14 Correct 150 ms 86392 KB Output is correct
15 Correct 248 ms 86520 KB Output is correct
16 Correct 149 ms 86520 KB Output is correct
17 Correct 249 ms 86392 KB Output is correct
18 Correct 252 ms 86552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 262 ms 86776 KB Output is correct
2 Correct 305 ms 86776 KB Output is correct
3 Correct 304 ms 87060 KB Output is correct
4 Correct 220 ms 87416 KB Output is correct
5 Correct 192 ms 87416 KB Output is correct
6 Correct 272 ms 87288 KB Output is correct
7 Correct 247 ms 86880 KB Output is correct
8 Correct 261 ms 86776 KB Output is correct
9 Correct 258 ms 86776 KB Output is correct
10 Correct 210 ms 86520 KB Output is correct
11 Correct 189 ms 86648 KB Output is correct
12 Correct 237 ms 86648 KB Output is correct
13 Correct 301 ms 87416 KB Output is correct
14 Correct 202 ms 87672 KB Output is correct
15 Correct 241 ms 86752 KB Output is correct
16 Correct 262 ms 86648 KB Output is correct
17 Correct 240 ms 86624 KB Output is correct
18 Correct 296 ms 86648 KB Output is correct
19 Correct 138 ms 86648 KB Output is correct
20 Correct 301 ms 87032 KB Output is correct
21 Correct 222 ms 87800 KB Output is correct
22 Correct 321 ms 87324 KB Output is correct
23 Correct 189 ms 87288 KB Output is correct
24 Correct 164 ms 87420 KB Output is correct
25 Correct 237 ms 87416 KB Output is correct
26 Correct 220 ms 87288 KB Output is correct
27 Correct 332 ms 86776 KB Output is correct
28 Correct 158 ms 87416 KB Output is correct
29 Correct 313 ms 87288 KB Output is correct
30 Correct 283 ms 87288 KB Output is correct
31 Correct 179 ms 87288 KB Output is correct
32 Correct 188 ms 87288 KB Output is correct
33 Correct 153 ms 87288 KB Output is correct
34 Correct 240 ms 86776 KB Output is correct
35 Correct 161 ms 87452 KB Output is correct
36 Correct 321 ms 87160 KB Output is correct
37 Correct 190 ms 87288 KB Output is correct
38 Correct 268 ms 87160 KB Output is correct
39 Correct 171 ms 87416 KB Output is correct
40 Correct 259 ms 87160 KB Output is correct
41 Correct 224 ms 86776 KB Output is correct
42 Correct 284 ms 87544 KB Output is correct