# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
31849 | 2017-09-11T07:12:59 Z | ngkan146 | Brunhilda’s Birthday (BOI13_brunhilda) | C++ | 606 ms | 155564 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(){ 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; deque <ii> dq; dq.push_back(ii(0,madiv[0]-1)); for(int i=1;i<=MAX;i++){ while(dq.size() && dq.front().fi + dq.front().se < i) dq.pop_front(); if (!dq.size()) break; assert(dq.size()); dp[i] = dp[dq.front().fi] + 1; dq.push_back(ii(i,madiv[i]-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 | 23 ms | 80532 KB | Output is correct |
2 | Correct | 216 ms | 80532 KB | Output is correct |
3 | Correct | 59 ms | 80532 KB | Output is correct |
4 | Correct | 199 ms | 80532 KB | Output is correct |
5 | Correct | 209 ms | 80532 KB | Output is correct |
6 | Correct | 16 ms | 80532 KB | Output is correct |
7 | Correct | 36 ms | 80532 KB | Output is correct |
8 | Correct | 53 ms | 80532 KB | Output is correct |
9 | Correct | 236 ms | 80532 KB | Output is correct |
10 | Correct | 266 ms | 80532 KB | Output is correct |
11 | Correct | 249 ms | 80532 KB | Output is correct |
12 | Correct | 183 ms | 80532 KB | Output is correct |
13 | Correct | 403 ms | 80664 KB | Output is correct |
14 | Correct | 436 ms | 80664 KB | Output is correct |
15 | Correct | 239 ms | 80532 KB | Output is correct |
16 | Correct | 219 ms | 80532 KB | Output is correct |
17 | Correct | 236 ms | 80532 KB | Output is correct |
18 | Correct | 203 ms | 80532 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 239 ms | 88116 KB | Output is correct |
2 | Correct | 276 ms | 155564 KB | Output is correct |
3 | Correct | 556 ms | 101240 KB | Output is correct |
4 | Correct | 253 ms | 81456 KB | Output is correct |
5 | Correct | 376 ms | 91284 KB | Output is correct |
6 | Correct | 213 ms | 81192 KB | Output is correct |
7 | Correct | 236 ms | 88116 KB | Output is correct |
8 | Correct | 256 ms | 80796 KB | Output is correct |
9 | Correct | 446 ms | 91284 KB | Output is correct |
10 | Correct | 529 ms | 101240 KB | Output is correct |
11 | Correct | 493 ms | 88248 KB | Output is correct |
12 | Correct | 309 ms | 80928 KB | Output is correct |
13 | Correct | 199 ms | 84788 KB | Output is correct |
14 | Correct | 266 ms | 81456 KB | Output is correct |
15 | Correct | 413 ms | 87264 KB | Output is correct |
16 | Correct | 266 ms | 155564 KB | Output is correct |
17 | Correct | 439 ms | 81060 KB | Output is correct |
18 | Correct | 443 ms | 121944 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 456 ms | 88908 KB | Output is correct |
2 | Correct | 556 ms | 86472 KB | Output is correct |
3 | Correct | 543 ms | 88644 KB | Output is correct |
4 | Correct | 369 ms | 81456 KB | Output is correct |
5 | Correct | 346 ms | 117588 KB | Output is correct |
6 | Correct | 473 ms | 81588 KB | Output is correct |
7 | Correct | 469 ms | 104144 KB | Output is correct |
8 | Correct | 526 ms | 88908 KB | Output is correct |
9 | Correct | 519 ms | 88908 KB | Output is correct |
10 | Correct | 389 ms | 81456 KB | Output is correct |
11 | Correct | 326 ms | 81456 KB | Output is correct |
12 | Correct | 439 ms | 81456 KB | Output is correct |
13 | Correct | 566 ms | 87288 KB | Output is correct |
14 | Correct | 349 ms | 80532 KB | Output is correct |
15 | Correct | 396 ms | 81192 KB | Output is correct |
16 | Correct | 486 ms | 81192 KB | Output is correct |
17 | Correct | 433 ms | 87264 KB | Output is correct |
18 | Correct | 606 ms | 86472 KB | Output is correct |
19 | Correct | 239 ms | 86696 KB | Output is correct |
20 | Correct | 599 ms | 88644 KB | Output is correct |
21 | Correct | 369 ms | 80532 KB | Output is correct |
22 | Correct | 579 ms | 93204 KB | Output is correct |
23 | Correct | 343 ms | 88908 KB | Output is correct |
24 | Correct | 273 ms | 81456 KB | Output is correct |
25 | Correct | 406 ms | 80928 KB | Output is correct |
26 | Correct | 376 ms | 81456 KB | Output is correct |
27 | Correct | 596 ms | 94392 KB | Output is correct |
28 | Correct | 239 ms | 82260 KB | Output is correct |
29 | Correct | 586 ms | 93204 KB | Output is correct |
30 | Correct | 549 ms | 88908 KB | Output is correct |
31 | Correct | 303 ms | 83040 KB | Output is correct |
32 | Correct | 329 ms | 81324 KB | Output is correct |
33 | Correct | 249 ms | 82248 KB | Output is correct |
34 | Correct | 463 ms | 104144 KB | Output is correct |
35 | Correct | 276 ms | 82132 KB | Output is correct |
36 | Correct | 553 ms | 93204 KB | Output is correct |
37 | Correct | 339 ms | 117588 KB | Output is correct |
38 | Correct | 473 ms | 81588 KB | Output is correct |
39 | Correct | 296 ms | 81588 KB | Output is correct |
40 | Correct | 466 ms | 82248 KB | Output is correct |
41 | Correct | 426 ms | 142364 KB | Output is correct |
42 | Correct | 526 ms | 81068 KB | Output is correct |