Submission #713947

# Submission time Handle Problem Language Result Execution time Memory
713947 2023-03-23T09:53:23 Z stevancv Brunhilda’s Birthday (BOI13_brunhilda) C++14
100 / 100
458 ms 157440 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 1e5 + 2;
const int M = 2e7 + 2;
const int inf = 1e9;
int dp[M], gde[M];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, q;
    cin >> n >> q;
    for (int i = 1; i <= n; i++) {
        int x; cin >> x;
        for (int j = x - 1; j < M; j += x) gde[j] = x - 1;
    }
    for (int i = M - 2; i >= 1; i--) {
        smax(gde[i], gde[i + 1] - 1);
    }
    for (int i = 1; i < M; i++) {
        if (gde[i] > 0) dp[i] = dp[i - gde[i]] + 1;
        else dp[i] = inf;
    }
    for (int i = 1; i <= q; i++) {
        int x; cin >> x;
        if (dp[x] >= inf) cout << "oo" << en;
        else cout << dp[x] << en;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 178 ms 156828 KB Output is correct
2 Correct 201 ms 156920 KB Output is correct
3 Correct 186 ms 156792 KB Output is correct
4 Correct 174 ms 156800 KB Output is correct
5 Correct 199 ms 156796 KB Output is correct
6 Correct 194 ms 156824 KB Output is correct
7 Correct 183 ms 156740 KB Output is correct
8 Correct 208 ms 156812 KB Output is correct
9 Correct 210 ms 156956 KB Output is correct
10 Correct 270 ms 156796 KB Output is correct
11 Correct 250 ms 156800 KB Output is correct
12 Correct 177 ms 156916 KB Output is correct
13 Correct 409 ms 156800 KB Output is correct
14 Correct 368 ms 156800 KB Output is correct
15 Correct 208 ms 156796 KB Output is correct
16 Correct 226 ms 156812 KB Output is correct
17 Correct 190 ms 156796 KB Output is correct
18 Correct 160 ms 156808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 193 ms 156856 KB Output is correct
2 Correct 212 ms 156796 KB Output is correct
3 Correct 450 ms 156856 KB Output is correct
4 Correct 205 ms 156944 KB Output is correct
5 Correct 296 ms 156932 KB Output is correct
6 Correct 184 ms 156800 KB Output is correct
7 Correct 173 ms 156800 KB Output is correct
8 Correct 198 ms 156800 KB Output is correct
9 Correct 348 ms 156936 KB Output is correct
10 Correct 415 ms 156828 KB Output is correct
11 Correct 429 ms 156888 KB Output is correct
12 Correct 249 ms 156748 KB Output is correct
13 Correct 175 ms 156812 KB Output is correct
14 Correct 204 ms 156876 KB Output is correct
15 Correct 352 ms 156800 KB Output is correct
16 Correct 192 ms 156804 KB Output is correct
17 Correct 355 ms 156900 KB Output is correct
18 Correct 356 ms 156816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 353 ms 156928 KB Output is correct
2 Correct 432 ms 156796 KB Output is correct
3 Correct 441 ms 157060 KB Output is correct
4 Correct 278 ms 157012 KB Output is correct
5 Correct 222 ms 157056 KB Output is correct
6 Correct 348 ms 157116 KB Output is correct
7 Correct 325 ms 156936 KB Output is correct
8 Correct 348 ms 156928 KB Output is correct
9 Correct 357 ms 156928 KB Output is correct
10 Correct 319 ms 156860 KB Output is correct
11 Correct 252 ms 156800 KB Output is correct
12 Correct 337 ms 156904 KB Output is correct
13 Correct 387 ms 157108 KB Output is correct
14 Correct 254 ms 157348 KB Output is correct
15 Correct 346 ms 156936 KB Output is correct
16 Correct 375 ms 156924 KB Output is correct
17 Correct 347 ms 156876 KB Output is correct
18 Correct 419 ms 156876 KB Output is correct
19 Correct 184 ms 156928 KB Output is correct
20 Correct 423 ms 156932 KB Output is correct
21 Correct 290 ms 157440 KB Output is correct
22 Correct 449 ms 157056 KB Output is correct
23 Correct 223 ms 157004 KB Output is correct
24 Correct 191 ms 157056 KB Output is correct
25 Correct 318 ms 157184 KB Output is correct
26 Correct 276 ms 157056 KB Output is correct
27 Correct 458 ms 156932 KB Output is correct
28 Correct 191 ms 157136 KB Output is correct
29 Correct 419 ms 157052 KB Output is correct
30 Correct 382 ms 157132 KB Output is correct
31 Correct 216 ms 157108 KB Output is correct
32 Correct 243 ms 157056 KB Output is correct
33 Correct 180 ms 157028 KB Output is correct
34 Correct 337 ms 156932 KB Output is correct
35 Correct 235 ms 157084 KB Output is correct
36 Correct 430 ms 157080 KB Output is correct
37 Correct 235 ms 157064 KB Output is correct
38 Correct 417 ms 157088 KB Output is correct
39 Correct 228 ms 157132 KB Output is correct
40 Correct 328 ms 157104 KB Output is correct
41 Correct 315 ms 156932 KB Output is correct
42 Correct 419 ms 157188 KB Output is correct