# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
493815 | 2021-12-13T03:56:36 Z | goodluck2020 | Brunhilda’s Birthday (BOI13_brunhilda) | C++14 | 507 ms | 157952 KB |
#include <bits/stdc++.h> #define task "brunhilda" using namespace std; const int N = 1e5 + 5; const int M = 2e7; int m, q, A[N], Q[N]; namespace sub1 { int dp[N]; void solve() { for(int i = 1; i <= 1e4; i++) dp[i] = 1e9; for(int i = 1; i <= 1e4; i++) for(int j = 1; j <= m; j++) dp[i] = min(dp[i], dp[i - i % A[j]] + 1); for(int i = 1; i <= q; i++) { if(dp[Q[i]] == 1e9) cout << "oo" << '\n'; else cout << dp[Q[i]] << '\n'; } } } namespace sub2 { int greed[M + 5], dp[M + 5]; long long lcm = 1; void solve() { for(int i = 1; i <= m; i++) lcm = min((long long)1e8,lcm * A[i]); for(int i = 1; i <= m; i++) for(int j = A[i] - 1; j <= M; j += A[i]) greed[j] = A[i] - 1; for(int i = M; i >= 1; i--) greed[i] = max(greed[i], greed[i + 1] - 1); for(int i = 1; i <= M; i++) dp[i] = dp[i - greed[i]] + 1; for(int i = 1; i <= q; i++) if(Q[i] >= lcm) cout << "oo" << '\n'; else cout << dp[Q[i]] << '\n'; } } int main() { if(fopen(task ".inp","r")) { freopen(task ".inp","r",stdin); freopen(task ".out","w",stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> m >> q; int maxN = 0; for(int i = 1; i <= m; i++) cin >> A[i]; for(int i = 1; i <= q; i++) cin >> Q[i], maxN = max(maxN, Q[i]); if(m <= 1e4 && q <= 1e4 && maxN <= 1e4) sub1::solve(); else sub2::solve(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 3 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 7 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 2 ms | 332 KB | Output is correct |
11 | Correct | 2 ms | 332 KB | Output is correct |
12 | Correct | 6 ms | 332 KB | Output is correct |
13 | Correct | 53 ms | 332 KB | Output is correct |
14 | Correct | 53 ms | 396 KB | Output is correct |
15 | Correct | 2 ms | 332 KB | Output is correct |
16 | Correct | 3 ms | 332 KB | Output is correct |
17 | Correct | 4 ms | 332 KB | Output is correct |
18 | Correct | 6 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 183 ms | 156944 KB | Output is correct |
2 | Correct | 200 ms | 157100 KB | Output is correct |
3 | Correct | 407 ms | 157076 KB | Output is correct |
4 | Correct | 204 ms | 156812 KB | Output is correct |
5 | Correct | 324 ms | 157156 KB | Output is correct |
6 | Correct | 185 ms | 156800 KB | Output is correct |
7 | Correct | 194 ms | 156856 KB | Output is correct |
8 | Correct | 209 ms | 156752 KB | Output is correct |
9 | Correct | 352 ms | 157072 KB | Output is correct |
10 | Correct | 416 ms | 157140 KB | Output is correct |
11 | Correct | 417 ms | 156964 KB | Output is correct |
12 | Correct | 247 ms | 156808 KB | Output is correct |
13 | Correct | 187 ms | 156860 KB | Output is correct |
14 | Correct | 205 ms | 156824 KB | Output is correct |
15 | Correct | 332 ms | 157008 KB | Output is correct |
16 | Correct | 194 ms | 157156 KB | Output is correct |
17 | Correct | 375 ms | 156772 KB | Output is correct |
18 | Correct | 376 ms | 157160 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 358 ms | 157276 KB | Output is correct |
2 | Correct | 501 ms | 157100 KB | Output is correct |
3 | Correct | 422 ms | 157448 KB | Output is correct |
4 | Correct | 287 ms | 157516 KB | Output is correct |
5 | Correct | 227 ms | 157824 KB | Output is correct |
6 | Correct | 386 ms | 157548 KB | Output is correct |
7 | Correct | 314 ms | 157520 KB | Output is correct |
8 | Correct | 388 ms | 157280 KB | Output is correct |
9 | Correct | 342 ms | 157216 KB | Output is correct |
10 | Correct | 288 ms | 156856 KB | Output is correct |
11 | Correct | 272 ms | 156928 KB | Output is correct |
12 | Correct | 323 ms | 156980 KB | Output is correct |
13 | Correct | 443 ms | 157532 KB | Output is correct |
14 | Correct | 260 ms | 157700 KB | Output is correct |
15 | Correct | 383 ms | 157044 KB | Output is correct |
16 | Correct | 387 ms | 157040 KB | Output is correct |
17 | Correct | 363 ms | 157020 KB | Output is correct |
18 | Correct | 439 ms | 157156 KB | Output is correct |
19 | Correct | 184 ms | 156904 KB | Output is correct |
20 | Correct | 436 ms | 157344 KB | Output is correct |
21 | Correct | 290 ms | 157824 KB | Output is correct |
22 | Correct | 442 ms | 157832 KB | Output is correct |
23 | Correct | 218 ms | 157588 KB | Output is correct |
24 | Correct | 213 ms | 157528 KB | Output is correct |
25 | Correct | 305 ms | 157572 KB | Output is correct |
26 | Correct | 289 ms | 157412 KB | Output is correct |
27 | Correct | 507 ms | 157520 KB | Output is correct |
28 | Correct | 196 ms | 157460 KB | Output is correct |
29 | Correct | 427 ms | 157828 KB | Output is correct |
30 | Correct | 423 ms | 157708 KB | Output is correct |
31 | Correct | 215 ms | 157404 KB | Output is correct |
32 | Correct | 253 ms | 157444 KB | Output is correct |
33 | Correct | 177 ms | 157472 KB | Output is correct |
34 | Correct | 322 ms | 157520 KB | Output is correct |
35 | Correct | 216 ms | 157508 KB | Output is correct |
36 | Correct | 434 ms | 157792 KB | Output is correct |
37 | Correct | 215 ms | 157952 KB | Output is correct |
38 | Correct | 354 ms | 157444 KB | Output is correct |
39 | Correct | 227 ms | 157452 KB | Output is correct |
40 | Correct | 317 ms | 157444 KB | Output is correct |
41 | Correct | 281 ms | 157524 KB | Output is correct |
42 | Correct | 380 ms | 157628 KB | Output is correct |