# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
31858 | 2017-09-11T07:49:44 Z | ngkan146 | Brunhilda’s Birthday (BOI13_brunhilda) | C++ | 473 ms | 80532 KB |
#include <bits/stdc++.h> #define fi first #define se second using namespace std; typedef pair<int,int> ii; const int MAX = (int) 1e7; int madiv[MAX+5]; int m,q; int p[100005]; int dp[MAX+5]; void prep(){ for(int i=1;i<=m;i++) for(int j=0;j<=MAX;j+=p[i]) madiv[j] = p[i]; } int main(){ //freopen("BRUNHILDA.inp","r",stdin); //freopen("BRUNHILDA.out","w",stdout); scanf("%d %d",&m,&q); for(int i=1;i<=m;i++) scanf("%d",&p[i]); prep(); for(int i=1;i<=MAX;i++) dp[i] = 10*MAX; int ctrl = 0; for(int i=1;i<=MAX;i++){ while(ctrl < i && ctrl + madiv[ctrl]-1 < i) ++ctrl; if (ctrl == i) break; dp[i] = dp[ctrl] + 1; } for(int i=1;i<=q;i++){ int n; scanf("%d",&n); if (dp[n] >= MAX) printf("oo\n"); else printf("%d\n",dp[n]); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 80532 KB | Output is correct |
2 | Correct | 73 ms | 80532 KB | Output is correct |
3 | Correct | 46 ms | 80532 KB | Output is correct |
4 | Correct | 63 ms | 80532 KB | Output is correct |
5 | Correct | 83 ms | 80532 KB | Output is correct |
6 | Correct | 29 ms | 80532 KB | Output is correct |
7 | Correct | 46 ms | 80532 KB | Output is correct |
8 | Correct | 46 ms | 80532 KB | Output is correct |
9 | Correct | 113 ms | 80532 KB | Output is correct |
10 | Correct | 126 ms | 80532 KB | Output is correct |
11 | Correct | 133 ms | 80532 KB | Output is correct |
12 | Correct | 56 ms | 80532 KB | Output is correct |
13 | Correct | 293 ms | 80532 KB | Output is correct |
14 | Correct | 299 ms | 80532 KB | Output is correct |
15 | Correct | 99 ms | 80532 KB | Output is correct |
16 | Correct | 83 ms | 80532 KB | Output is correct |
17 | Correct | 93 ms | 80532 KB | Output is correct |
18 | Correct | 63 ms | 80532 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 83 ms | 80532 KB | Output is correct |
2 | Correct | 96 ms | 80532 KB | Output is correct |
3 | Correct | 416 ms | 80532 KB | Output is correct |
4 | Correct | 109 ms | 80532 KB | Output is correct |
5 | Correct | 243 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 | 113 ms | 80532 KB | Output is correct |
9 | Correct | 383 ms | 80532 KB | Output is correct |
10 | Correct | 433 ms | 80532 KB | Output is correct |
11 | Correct | 386 ms | 80532 KB | Output is correct |
12 | Correct | 199 ms | 80532 KB | Output is correct |
13 | Correct | 43 ms | 80532 KB | Output is correct |
14 | Correct | 136 ms | 80532 KB | Output is correct |
15 | Correct | 296 ms | 80532 KB | Output is correct |
16 | Correct | 109 ms | 80532 KB | Output is correct |
17 | Correct | 306 ms | 80532 KB | Output is correct |
18 | Correct | 356 ms | 80532 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 309 ms | 80532 KB | Output is correct |
2 | Correct | 399 ms | 80532 KB | Output is correct |
3 | Correct | 459 ms | 80532 KB | Output is correct |
4 | Correct | 229 ms | 80532 KB | Output is correct |
5 | Correct | 156 ms | 80532 KB | Output is correct |
6 | Correct | 349 ms | 80532 KB | Output is correct |
7 | Correct | 319 ms | 80532 KB | Output is correct |
8 | Correct | 343 ms | 80532 KB | Output is correct |
9 | Correct | 279 ms | 80532 KB | Output is correct |
10 | Correct | 236 ms | 80532 KB | Output is correct |
11 | Correct | 179 ms | 80532 KB | Output is correct |
12 | Correct | 299 ms | 80532 KB | Output is correct |
13 | Correct | 389 ms | 80532 KB | Output is correct |
14 | Correct | 216 ms | 80532 KB | Output is correct |
15 | Correct | 299 ms | 80532 KB | Output is correct |
16 | Correct | 389 ms | 80532 KB | Output is correct |
17 | Correct | 316 ms | 80532 KB | Output is correct |
18 | Correct | 419 ms | 80532 KB | Output is correct |
19 | Correct | 86 ms | 80532 KB | Output is correct |
20 | Correct | 423 ms | 80532 KB | Output is correct |
21 | Correct | 239 ms | 80532 KB | Output is correct |
22 | Correct | 473 ms | 80532 KB | Output is correct |
23 | Correct | 176 ms | 80532 KB | Output is correct |
24 | Correct | 129 ms | 80532 KB | Output is correct |
25 | Correct | 273 ms | 80532 KB | Output is correct |
26 | Correct | 233 ms | 80532 KB | Output is correct |
27 | Correct | 466 ms | 80532 KB | Output is correct |
28 | Correct | 106 ms | 80532 KB | Output is correct |
29 | Correct | 426 ms | 80532 KB | Output is correct |
30 | Correct | 369 ms | 80532 KB | Output is correct |
31 | Correct | 153 ms | 80532 KB | Output is correct |
32 | Correct | 176 ms | 80532 KB | Output is correct |
33 | Correct | 86 ms | 80532 KB | Output is correct |
34 | Correct | 303 ms | 80532 KB | Output is correct |
35 | Correct | 116 ms | 80532 KB | Output is correct |
36 | Correct | 396 ms | 80532 KB | Output is correct |
37 | Correct | 149 ms | 80532 KB | Output is correct |
38 | Correct | 313 ms | 80532 KB | Output is correct |
39 | Correct | 133 ms | 80532 KB | Output is correct |
40 | Correct | 263 ms | 80532 KB | Output is correct |
41 | Correct | 223 ms | 80532 KB | Output is correct |
42 | Correct | 393 ms | 80532 KB | Output is correct |