Submission #152529

# Submission time Handle Problem Language Result Execution time Memory
152529 2019-09-08T09:19:26 Z dolphingarlic Brunhilda’s Birthday (BOI13_brunhilda) C++14
77.4603 / 100
635 ms 237780 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 + 10], p[100001], max_divide[MAXN + 10], to[MAXN + 10];

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 220 ms 235256 KB Output is correct
2 Correct 254 ms 235216 KB Output is correct
3 Correct 237 ms 235100 KB Output is correct
4 Correct 226 ms 235224 KB Output is correct
5 Correct 235 ms 235188 KB Output is correct
6 Correct 220 ms 235128 KB Output is correct
7 Correct 258 ms 235144 KB Output is correct
8 Correct 254 ms 235204 KB Output is correct
9 Correct 291 ms 235224 KB Output is correct
10 Correct 313 ms 235124 KB Output is correct
11 Correct 308 ms 235176 KB Output is correct
12 Correct 213 ms 235104 KB Output is correct
13 Correct 458 ms 235244 KB Output is correct
14 Correct 454 ms 235240 KB Output is correct
15 Correct 267 ms 235128 KB Output is correct
16 Correct 251 ms 235228 KB Output is correct
17 Correct 253 ms 235264 KB Output is correct
18 Correct 222 ms 235268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 240 ms 235344 KB Output is correct
2 Correct 253 ms 236648 KB Output is correct
3 Correct 555 ms 236248 KB Output is correct
4 Correct 272 ms 235256 KB Output is correct
5 Correct 400 ms 235904 KB Output is correct
6 Correct 290 ms 235212 KB Output is correct
7 Correct 283 ms 235388 KB Output is correct
8 Correct 270 ms 235236 KB Output is correct
9 Correct 479 ms 236160 KB Output is correct
10 Correct 556 ms 236252 KB Output is correct
11 Incorrect 528 ms 235772 KB Output isn't correct
12 Correct 337 ms 235220 KB Output is correct
13 Correct 230 ms 235220 KB Output is correct
14 Correct 271 ms 235256 KB Output is correct
15 Correct 454 ms 235764 KB Output is correct
16 Correct 262 ms 236632 KB Output is correct
17 Correct 468 ms 235256 KB Output is correct
18 Correct 472 ms 236688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 485 ms 236360 KB Output is correct
2 Correct 538 ms 236128 KB Output is correct
3 Correct 542 ms 236512 KB Output is correct
4 Incorrect 371 ms 236120 KB Output isn't correct
5 Incorrect 301 ms 237644 KB Output isn't correct
6 Correct 461 ms 236212 KB Output is correct
7 Correct 422 ms 237264 KB Output is correct
8 Correct 458 ms 236236 KB Output is correct
9 Correct 460 ms 236236 KB Output is correct
10 Correct 411 ms 235412 KB Output is correct
11 Incorrect 360 ms 235640 KB Output isn't correct
12 Correct 521 ms 235504 KB Output is correct
13 Correct 522 ms 236588 KB Output is correct
14 Correct 347 ms 236552 KB Output is correct
15 Incorrect 462 ms 235504 KB Output isn't correct
16 Correct 508 ms 235512 KB Output is correct
17 Correct 433 ms 235908 KB Output is correct
18 Correct 543 ms 236128 KB Output is correct
19 Incorrect 245 ms 235420 KB Output isn't correct
20 Correct 540 ms 236500 KB Output is correct
21 Incorrect 393 ms 236536 KB Output isn't correct
22 Correct 554 ms 237688 KB Output is correct
23 Correct 308 ms 236612 KB Output is correct
24 Correct 294 ms 236340 KB Output is correct
25 Incorrect 462 ms 236408 KB Output isn't correct
26 Incorrect 375 ms 236180 KB Output isn't correct
27 Correct 635 ms 237304 KB Output is correct
28 Incorrect 261 ms 236280 KB Output isn't correct
29 Correct 519 ms 237780 KB Output is correct
30 Correct 476 ms 237304 KB Output is correct
31 Correct 289 ms 236280 KB Output is correct
32 Incorrect 324 ms 236152 KB Output isn't correct
33 Incorrect 266 ms 236236 KB Output isn't correct
34 Correct 401 ms 237196 KB Output is correct
35 Incorrect 275 ms 236280 KB Output isn't correct
36 Correct 555 ms 237560 KB Output is correct
37 Incorrect 301 ms 237688 KB Output isn't correct
38 Correct 466 ms 236336 KB Output is correct
39 Incorrect 282 ms 236280 KB Output isn't correct
40 Correct 448 ms 236300 KB Output is correct
41 Correct 373 ms 237364 KB Output is correct
42 Incorrect 510 ms 236508 KB Output isn't correct