# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
155781 | 2019-09-30T14:13:23 Z | karma | Brunhilda’s Birthday (BOI13_brunhilda) | C++14 | 413 ms | 79352 KB |
#include<bits/stdc++.h> #define Task "test" #define pb emplace_back using namespace std; const int N = int(1e7) + 1; const int inf = int(1e9); int nxt[N], f[N], m, Q, n, x; int main() { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); if(fopen(Task".inp", "r")) { freopen(Task".inp", "r", stdin); freopen(Task".out", "w", stdout); } cin >> m >> Q; while(m --) { cin >> x; for(int i = x; i <= N; i += x) nxt[i - 1] = max(nxt[i - 1], x - 1); nxt[N - 1] = max(nxt[N - 1], (N - 1) % x); } for(int i = N - 1; i >= 1; --i) nxt[i] = max(nxt[i], nxt[i + 1] - 1); for(int i = 1; i < N; ++i) { if(nxt[i]) f[i] = f[i - nxt[i]] + 1; else f[i] = inf; } while(Q --) { cin >> x; if(f[x] >= inf) cout << "oo\n"; else cout << f[x] << '\n'; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 147 ms | 78584 KB | Output is correct |
2 | Correct | 176 ms | 78660 KB | Output is correct |
3 | Correct | 162 ms | 78616 KB | Output is correct |
4 | Correct | 141 ms | 78684 KB | Output is correct |
5 | Correct | 152 ms | 78564 KB | Output is correct |
6 | Correct | 134 ms | 78584 KB | Output is correct |
7 | Correct | 144 ms | 78632 KB | Output is correct |
8 | Correct | 147 ms | 78676 KB | Output is correct |
9 | Correct | 166 ms | 78588 KB | Output is correct |
10 | Correct | 186 ms | 78584 KB | Output is correct |
11 | Correct | 180 ms | 78692 KB | Output is correct |
12 | Correct | 134 ms | 78608 KB | Output is correct |
13 | Correct | 294 ms | 78588 KB | Output is correct |
14 | Correct | 333 ms | 78616 KB | Output is correct |
15 | Correct | 163 ms | 78584 KB | Output is correct |
16 | Correct | 180 ms | 78556 KB | Output is correct |
17 | Correct | 176 ms | 78596 KB | Output is correct |
18 | Correct | 135 ms | 78712 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 162 ms | 78584 KB | Output is correct |
2 | Correct | 177 ms | 78584 KB | Output is correct |
3 | Correct | 353 ms | 78716 KB | Output is correct |
4 | Correct | 169 ms | 78644 KB | Output is correct |
5 | Correct | 259 ms | 78584 KB | Output is correct |
6 | Correct | 155 ms | 78580 KB | Output is correct |
7 | Correct | 149 ms | 78584 KB | Output is correct |
8 | Correct | 177 ms | 78564 KB | Output is correct |
9 | Correct | 287 ms | 78584 KB | Output is correct |
10 | Correct | 399 ms | 78584 KB | Output is correct |
11 | Correct | 375 ms | 78584 KB | Output is correct |
12 | Correct | 213 ms | 78600 KB | Output is correct |
13 | Correct | 147 ms | 78584 KB | Output is correct |
14 | Correct | 169 ms | 78556 KB | Output is correct |
15 | Correct | 286 ms | 78568 KB | Output is correct |
16 | Correct | 171 ms | 78588 KB | Output is correct |
17 | Correct | 296 ms | 78564 KB | Output is correct |
18 | Correct | 287 ms | 78584 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 295 ms | 78668 KB | Output is correct |
2 | Correct | 338 ms | 78692 KB | Output is correct |
3 | Correct | 345 ms | 78816 KB | Output is correct |
4 | Correct | 240 ms | 78968 KB | Output is correct |
5 | Correct | 203 ms | 78840 KB | Output is correct |
6 | Correct | 349 ms | 78988 KB | Output is correct |
7 | Correct | 271 ms | 78712 KB | Output is correct |
8 | Correct | 347 ms | 78700 KB | Output is correct |
9 | Correct | 303 ms | 78732 KB | Output is correct |
10 | Correct | 238 ms | 78720 KB | Output is correct |
11 | Correct | 211 ms | 78824 KB | Output is correct |
12 | Correct | 272 ms | 78712 KB | Output is correct |
13 | Correct | 340 ms | 78968 KB | Output is correct |
14 | Correct | 214 ms | 79352 KB | Output is correct |
15 | Correct | 278 ms | 78712 KB | Output is correct |
16 | Correct | 303 ms | 78712 KB | Output is correct |
17 | Correct | 274 ms | 78584 KB | Output is correct |
18 | Correct | 338 ms | 78692 KB | Output is correct |
19 | Correct | 152 ms | 78712 KB | Output is correct |
20 | Correct | 357 ms | 78820 KB | Output is correct |
21 | Correct | 244 ms | 79228 KB | Output is correct |
22 | Correct | 388 ms | 78840 KB | Output is correct |
23 | Correct | 223 ms | 78968 KB | Output is correct |
24 | Correct | 179 ms | 78944 KB | Output is correct |
25 | Correct | 293 ms | 78932 KB | Output is correct |
26 | Correct | 233 ms | 78840 KB | Output is correct |
27 | Correct | 367 ms | 78712 KB | Output is correct |
28 | Correct | 170 ms | 78860 KB | Output is correct |
29 | Correct | 341 ms | 78840 KB | Output is correct |
30 | Correct | 391 ms | 78944 KB | Output is correct |
31 | Correct | 207 ms | 78840 KB | Output is correct |
32 | Correct | 203 ms | 78840 KB | Output is correct |
33 | Correct | 157 ms | 78964 KB | Output is correct |
34 | Correct | 268 ms | 78692 KB | Output is correct |
35 | Correct | 172 ms | 78840 KB | Output is correct |
36 | Correct | 359 ms | 78968 KB | Output is correct |
37 | Correct | 204 ms | 78776 KB | Output is correct |
38 | Correct | 303 ms | 78820 KB | Output is correct |
39 | Correct | 188 ms | 78972 KB | Output is correct |
40 | Correct | 259 ms | 78840 KB | Output is correct |
41 | Correct | 296 ms | 78684 KB | Output is correct |
42 | Correct | 413 ms | 78980 KB | Output is correct |