# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
30900 | 2017-07-31T13:41:34 Z | Navick | Brunhilda’s Birthday (BOI13_brunhilda) | C++14 | 843 ms | 158268 KB |
#include <bits/stdc++.h> #define F first #define S second #define pii pair<int, int> #define pb push_back using namespace std; typedef long long ll; typedef long double ld; const int N = 1e7 + 10, INF = 1e9; int dp[N], p[N], rm[2 * N]; int main(){ int m, q; scanf("%d %d", &m, &q); for(int i=0; i<m; i++){ scanf("%d", p + i); for(int k=p[i] - 1; k<2 * N; k+=p[i]) rm[k] = p[i] - 1; } for(int i=2*N-1; i>=1; i--) rm[i] = max(rm[i], rm[i + 1] - 1); for(int i=1; i<N; i++){ if(rm[i] == 0){ break; }else{ dp[i] = dp[i - rm[i]] + 1; } } for(int i=0; i<q; i++){ int n; scanf("%d", &n); if(dp[n] == 0) printf("oo\n"); else printf("%d\n", dp[n]); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 106 ms | 158268 KB | Output is correct |
2 | Correct | 189 ms | 158268 KB | Output is correct |
3 | Correct | 123 ms | 158268 KB | Output is correct |
4 | Correct | 153 ms | 158268 KB | Output is correct |
5 | Correct | 176 ms | 158268 KB | Output is correct |
6 | Correct | 96 ms | 158268 KB | Output is correct |
7 | Correct | 126 ms | 158268 KB | Output is correct |
8 | Correct | 136 ms | 158268 KB | Output is correct |
9 | Correct | 199 ms | 158268 KB | Output is correct |
10 | Correct | 269 ms | 158268 KB | Output is correct |
11 | Correct | 249 ms | 158268 KB | Output is correct |
12 | Correct | 126 ms | 158268 KB | Output is correct |
13 | Correct | 583 ms | 158268 KB | Output is correct |
14 | Correct | 539 ms | 158268 KB | Output is correct |
15 | Correct | 199 ms | 158268 KB | Output is correct |
16 | Correct | 186 ms | 158268 KB | Output is correct |
17 | Correct | 203 ms | 158268 KB | Output is correct |
18 | Correct | 133 ms | 158268 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 186 ms | 158268 KB | Output is correct |
2 | Correct | 213 ms | 158268 KB | Output is correct |
3 | Correct | 736 ms | 158268 KB | Output is correct |
4 | Correct | 253 ms | 158268 KB | Output is correct |
5 | Correct | 463 ms | 158268 KB | Output is correct |
6 | Correct | 186 ms | 158268 KB | Output is correct |
7 | Correct | 186 ms | 158268 KB | Output is correct |
8 | Correct | 253 ms | 158268 KB | Output is correct |
9 | Correct | 603 ms | 158268 KB | Output is correct |
10 | Correct | 756 ms | 158268 KB | Output is correct |
11 | Correct | 749 ms | 158268 KB | Output is correct |
12 | Correct | 353 ms | 158268 KB | Output is correct |
13 | Correct | 159 ms | 158268 KB | Output is correct |
14 | Correct | 243 ms | 158268 KB | Output is correct |
15 | Correct | 593 ms | 158268 KB | Output is correct |
16 | Correct | 226 ms | 158268 KB | Output is correct |
17 | Correct | 593 ms | 158268 KB | Output is correct |
18 | Correct | 569 ms | 158268 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 563 ms | 158268 KB | Output is correct |
2 | Correct | 729 ms | 158268 KB | Output is correct |
3 | Correct | 779 ms | 158268 KB | Output is correct |
4 | Correct | 399 ms | 158268 KB | Output is correct |
5 | Correct | 269 ms | 158268 KB | Output is correct |
6 | Correct | 546 ms | 158268 KB | Output is correct |
7 | Correct | 509 ms | 158268 KB | Output is correct |
8 | Correct | 573 ms | 158268 KB | Output is correct |
9 | Correct | 569 ms | 158268 KB | Output is correct |
10 | Correct | 466 ms | 158268 KB | Output is correct |
11 | Correct | 393 ms | 158268 KB | Output is correct |
12 | Correct | 526 ms | 158268 KB | Output is correct |
13 | Correct | 699 ms | 158268 KB | Output is correct |
14 | Correct | 326 ms | 158268 KB | Output is correct |
15 | Correct | 569 ms | 158268 KB | Output is correct |
16 | Correct | 676 ms | 158268 KB | Output is correct |
17 | Correct | 599 ms | 158268 KB | Output is correct |
18 | Correct | 793 ms | 158268 KB | Output is correct |
19 | Correct | 169 ms | 158268 KB | Output is correct |
20 | Correct | 813 ms | 158268 KB | Output is correct |
21 | Correct | 416 ms | 158268 KB | Output is correct |
22 | Correct | 789 ms | 158268 KB | Output is correct |
23 | Correct | 299 ms | 158268 KB | Output is correct |
24 | Correct | 189 ms | 158268 KB | Output is correct |
25 | Correct | 483 ms | 158268 KB | Output is correct |
26 | Correct | 399 ms | 158268 KB | Output is correct |
27 | Correct | 843 ms | 158268 KB | Output is correct |
28 | Correct | 199 ms | 158268 KB | Output is correct |
29 | Correct | 749 ms | 158268 KB | Output is correct |
30 | Correct | 643 ms | 158268 KB | Output is correct |
31 | Correct | 249 ms | 158268 KB | Output is correct |
32 | Correct | 309 ms | 158268 KB | Output is correct |
33 | Correct | 173 ms | 158268 KB | Output is correct |
34 | Correct | 523 ms | 158268 KB | Output is correct |
35 | Correct | 229 ms | 158268 KB | Output is correct |
36 | Correct | 766 ms | 158268 KB | Output is correct |
37 | Correct | 289 ms | 158268 KB | Output is correct |
38 | Correct | 559 ms | 158268 KB | Output is correct |
39 | Correct | 239 ms | 158268 KB | Output is correct |
40 | Correct | 499 ms | 158268 KB | Output is correct |
41 | Correct | 446 ms | 158268 KB | Output is correct |
42 | Correct | 626 ms | 158268 KB | Output is correct |