Submission #152516

# Submission time Handle Problem Language Result Execution time Memory
152516 2019-09-08T08:55:44 Z dolphingarlic Brunhilda’s Birthday (BOI13_brunhilda) C++14
77.4603 / 100
664 ms 236280 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 - 1;
    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 216 ms 235256 KB Output is correct
2 Correct 257 ms 235156 KB Output is correct
3 Correct 236 ms 235100 KB Output is correct
4 Correct 213 ms 235132 KB Output is correct
5 Correct 233 ms 235092 KB Output is correct
6 Correct 247 ms 235216 KB Output is correct
7 Correct 236 ms 235260 KB Output is correct
8 Correct 248 ms 235252 KB Output is correct
9 Correct 275 ms 235128 KB Output is correct
10 Correct 306 ms 235256 KB Output is correct
11 Correct 289 ms 235296 KB Output is correct
12 Correct 211 ms 235144 KB Output is correct
13 Correct 501 ms 235308 KB Output is correct
14 Correct 452 ms 235224 KB Output is correct
15 Correct 262 ms 235128 KB Output is correct
16 Correct 247 ms 235160 KB Output is correct
17 Correct 246 ms 235128 KB Output is correct
18 Correct 223 ms 235208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 237 ms 235204 KB Output is correct
2 Correct 250 ms 235896 KB Output is correct
3 Correct 540 ms 235768 KB Output is correct
4 Correct 268 ms 235336 KB Output is correct
5 Correct 390 ms 235644 KB Output is correct
6 Correct 242 ms 235256 KB Output is correct
7 Correct 238 ms 235324 KB Output is correct
8 Correct 269 ms 235128 KB Output is correct
9 Correct 432 ms 235896 KB Output is correct
10 Correct 575 ms 235860 KB Output is correct
11 Incorrect 592 ms 235568 KB Output isn't correct
12 Correct 349 ms 235256 KB Output is correct
13 Correct 225 ms 235228 KB Output is correct
14 Correct 281 ms 235380 KB Output is correct
15 Correct 467 ms 235512 KB Output is correct
16 Correct 250 ms 235896 KB Output is correct
17 Correct 461 ms 235256 KB Output is correct
18 Correct 444 ms 235896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 461 ms 235736 KB Output is correct
2 Correct 538 ms 235632 KB Output is correct
3 Correct 547 ms 235876 KB Output is correct
4 Incorrect 371 ms 235500 KB Output isn't correct
5 Incorrect 292 ms 236156 KB Output isn't correct
6 Correct 463 ms 235516 KB Output is correct
7 Correct 399 ms 236000 KB Output is correct
8 Correct 464 ms 235740 KB Output is correct
9 Correct 461 ms 235640 KB Output is correct
10 Correct 379 ms 235256 KB Output is correct
11 Incorrect 332 ms 235248 KB Output isn't correct
12 Correct 454 ms 235260 KB Output is correct
13 Correct 527 ms 235696 KB Output is correct
14 Correct 363 ms 235820 KB Output is correct
15 Incorrect 455 ms 235256 KB Output isn't correct
16 Correct 493 ms 235384 KB Output is correct
17 Correct 428 ms 235640 KB Output is correct
18 Correct 608 ms 235628 KB Output is correct
19 Incorrect 233 ms 235356 KB Output isn't correct
20 Correct 543 ms 235768 KB Output is correct
21 Incorrect 383 ms 235896 KB Output isn't correct
22 Correct 549 ms 236280 KB Output is correct
23 Correct 294 ms 235640 KB Output is correct
24 Correct 256 ms 235512 KB Output is correct
25 Incorrect 392 ms 235512 KB Output isn't correct
26 Incorrect 377 ms 235512 KB Output isn't correct
27 Correct 664 ms 236252 KB Output is correct
28 Incorrect 279 ms 235580 KB Output isn't correct
29 Correct 515 ms 236152 KB Output is correct
30 Correct 480 ms 235896 KB Output is correct
31 Correct 285 ms 235384 KB Output is correct
32 Incorrect 311 ms 235408 KB Output isn't correct
33 Incorrect 240 ms 235384 KB Output isn't correct
34 Correct 457 ms 236152 KB Output is correct
35 Incorrect 266 ms 235512 KB Output isn't correct
36 Correct 533 ms 236124 KB Output is correct
37 Incorrect 290 ms 236152 KB Output isn't correct
38 Correct 463 ms 235472 KB Output is correct
39 Incorrect 272 ms 235512 KB Output isn't correct
40 Correct 407 ms 235512 KB Output is correct
41 Correct 367 ms 236124 KB Output is correct
42 Incorrect 503 ms 235684 KB Output isn't correct