Submission #152515

# Submission time Handle Problem Language Result Execution time Memory
152515 2019-09-08T08:55:04 Z dolphingarlic Brunhilda’s Birthday (BOI13_brunhilda) C++14
77.4603 / 100
621 ms 236408 KB
#include <bits/stdc++.h>
#pragma GCC Optimize("O3")
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define MAXN 10000001
typedef long long ll;
using namespace std;

ll dp[MAXN], p[100001], max_divide[MAXN], to[MAXN];

int main() {
    iostream::sync_with_stdio(false);
    cin.tie(0);

    int n, q;
    cin >> n >> q;
    FOR(i, 0, n) cin >> p[i];
    FOR(i, 0, n) for (int j = p[i]; j <= MAXN; j += p[i]) max_divide[j] = p[i];

    ll mn = MAXN;
    for (int i = MAXN - 1; i > 0; i--) {
        mn = min(mn, i + 1 - max_divide[i + 1]);
        to[i] = mn;
    }

    FOR(i, 1, MAXN) if (to[i] == i) dp[i] = INT_MAX;
    else dp[i] = dp[to[i]] + 1;

    FOR(i, 0, q) {
        int x;
        cin >> x;
        if (dp[x] >= INT_MAX)
            cout << "oo\n";
        else
            cout << dp[x] << '\n';
    }
    return 0;
}

Compilation message

brunhilda.cpp:2:0: warning: ignoring #pragma GCC Optimize [-Wunknown-pragmas]
 #pragma GCC Optimize("O3")
# Verdict Execution time Memory Grader output
1 Correct 212 ms 235256 KB Output is correct
2 Correct 247 ms 235128 KB Output is correct
3 Correct 233 ms 235132 KB Output is correct
4 Correct 236 ms 235280 KB Output is correct
5 Correct 237 ms 235268 KB Output is correct
6 Correct 216 ms 235208 KB Output is correct
7 Correct 233 ms 235128 KB Output is correct
8 Correct 261 ms 235212 KB Output is correct
9 Correct 280 ms 235292 KB Output is correct
10 Correct 304 ms 235256 KB Output is correct
11 Correct 288 ms 235256 KB Output is correct
12 Correct 213 ms 235136 KB Output is correct
13 Correct 450 ms 235288 KB Output is correct
14 Correct 450 ms 235276 KB Output is correct
15 Correct 259 ms 235224 KB Output is correct
16 Correct 248 ms 235256 KB Output is correct
17 Correct 255 ms 235384 KB Output is correct
18 Correct 216 ms 235256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 251 ms 235340 KB Output is correct
2 Correct 258 ms 236024 KB Output is correct
3 Correct 551 ms 235960 KB Output is correct
4 Correct 268 ms 235408 KB Output is correct
5 Correct 393 ms 235812 KB Output is correct
6 Correct 246 ms 235164 KB Output is correct
7 Correct 238 ms 235284 KB Output is correct
8 Correct 266 ms 235356 KB Output is correct
9 Correct 433 ms 235912 KB Output is correct
10 Correct 564 ms 235900 KB Output is correct
11 Incorrect 515 ms 235660 KB Output isn't correct
12 Correct 332 ms 235256 KB Output is correct
13 Correct 225 ms 235256 KB Output is correct
14 Correct 269 ms 235300 KB Output is correct
15 Correct 446 ms 235640 KB Output is correct
16 Correct 251 ms 236068 KB Output is correct
17 Correct 465 ms 235384 KB Output is correct
18 Correct 477 ms 236040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 511 ms 235768 KB Output is correct
2 Correct 540 ms 235640 KB Output is correct
3 Correct 621 ms 235896 KB Output is correct
4 Incorrect 373 ms 235768 KB Output isn't correct
5 Incorrect 292 ms 236356 KB Output isn't correct
6 Correct 464 ms 235768 KB Output is correct
7 Correct 403 ms 236152 KB Output is correct
8 Correct 463 ms 235732 KB Output is correct
9 Correct 486 ms 235796 KB Output is correct
10 Correct 417 ms 235384 KB Output is correct
11 Incorrect 334 ms 235512 KB Output isn't correct
12 Correct 429 ms 235584 KB Output is correct
13 Correct 532 ms 236024 KB Output is correct
14 Correct 343 ms 236024 KB Output is correct
15 Incorrect 449 ms 235488 KB Output isn't correct
16 Correct 520 ms 235416 KB Output is correct
17 Correct 428 ms 235896 KB Output is correct
18 Correct 539 ms 235768 KB Output is correct
19 Incorrect 237 ms 235516 KB Output isn't correct
20 Correct 598 ms 235996 KB Output is correct
21 Incorrect 389 ms 236036 KB Output isn't correct
22 Correct 552 ms 236380 KB Output is correct
23 Correct 299 ms 235896 KB Output is correct
24 Correct 257 ms 235760 KB Output is correct
25 Incorrect 395 ms 235896 KB Output isn't correct
26 Incorrect 382 ms 235796 KB Output isn't correct
27 Correct 588 ms 236116 KB Output is correct
28 Incorrect 260 ms 235764 KB Output isn't correct
29 Correct 528 ms 236408 KB Output is correct
30 Correct 472 ms 236024 KB Output is correct
31 Correct 303 ms 235936 KB Output is correct
32 Incorrect 306 ms 235868 KB Output isn't correct
33 Incorrect 240 ms 235640 KB Output isn't correct
34 Correct 424 ms 236360 KB Output is correct
35 Incorrect 266 ms 235852 KB Output isn't correct
36 Correct 539 ms 236280 KB Output is correct
37 Incorrect 297 ms 236400 KB Output isn't correct
38 Correct 469 ms 235768 KB Output is correct
39 Incorrect 272 ms 235768 KB Output isn't correct
40 Correct 409 ms 235880 KB Output is correct
41 Correct 368 ms 236152 KB Output is correct
42 Incorrect 504 ms 235860 KB Output isn't correct