Submission #155730

# Submission time Handle Problem Language Result Execution time Memory
155730 2019-09-30T07:02:18 Z atoiz Brunhilda’s Birthday (BOI13_brunhilda) C++14
100 / 100
47 ms 1476 KB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int MAXM = 100007, MAXA = 1000007, MAXV = 10000007;
int Q, M;
int P[MAXM], R[MAXA], last;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> M >> Q;
    for (int i = 0; i < M; ++i) cin >> P[i];

    R[last = 0] = 0;
    while (R[last] < MAXV) {
        int nxt = -1;
        for (int i = 0; i < M; ++i) nxt = max(nxt, R[last] - (R[last] % P[i]) + P[i] - 1);
        if (nxt <= R[last]) break;
        R[++last] = nxt;
    }

    for (int q = 0; q < Q; ++q) {
        int x;
        cin >> x;
        if (x > R[last]) cout << "oo\n";
        else cout << lower_bound(R, R + last + 1, x) - R << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 7 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 10 ms 1016 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 452 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 16 ms 1476 KB Output is correct
10 Correct 10 ms 632 KB Output is correct
11 Correct 10 ms 620 KB Output is correct
12 Correct 4 ms 380 KB Output is correct
13 Correct 8 ms 380 KB Output is correct
14 Correct 9 ms 376 KB Output is correct
15 Correct 6 ms 504 KB Output is correct
16 Correct 7 ms 376 KB Output is correct
17 Correct 9 ms 504 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 14 ms 632 KB Output is correct
3 Correct 12 ms 632 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 9 ms 504 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 4 ms 312 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 13 ms 668 KB Output is correct
10 Correct 12 ms 632 KB Output is correct
11 Correct 10 ms 504 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 4 ms 380 KB Output is correct
15 Correct 9 ms 504 KB Output is correct
16 Correct 14 ms 632 KB Output is correct
17 Correct 6 ms 376 KB Output is correct
18 Correct 15 ms 676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 632 KB Output is correct
2 Correct 17 ms 604 KB Output is correct
3 Correct 22 ms 632 KB Output is correct
4 Correct 25 ms 632 KB Output is correct
5 Correct 34 ms 888 KB Output is correct
6 Correct 28 ms 648 KB Output is correct
7 Correct 27 ms 888 KB Output is correct
8 Correct 18 ms 632 KB Output is correct
9 Correct 18 ms 632 KB Output is correct
10 Correct 8 ms 376 KB Output is correct
11 Correct 10 ms 376 KB Output is correct
12 Correct 11 ms 376 KB Output is correct
13 Correct 27 ms 760 KB Output is correct
14 Correct 35 ms 1272 KB Output is correct
15 Correct 12 ms 504 KB Output is correct
16 Correct 12 ms 376 KB Output is correct
17 Correct 12 ms 504 KB Output is correct
18 Correct 17 ms 632 KB Output is correct
19 Correct 8 ms 376 KB Output is correct
20 Correct 22 ms 648 KB Output is correct
21 Correct 31 ms 988 KB Output is correct
22 Correct 37 ms 916 KB Output is correct
23 Correct 28 ms 632 KB Output is correct
24 Correct 26 ms 636 KB Output is correct
25 Correct 29 ms 760 KB Output is correct
26 Correct 25 ms 636 KB Output is correct
27 Correct 28 ms 888 KB Output is correct
28 Correct 24 ms 632 KB Output is correct
29 Correct 37 ms 1016 KB Output is correct
30 Correct 35 ms 888 KB Output is correct
31 Correct 23 ms 632 KB Output is correct
32 Correct 26 ms 632 KB Output is correct
33 Correct 47 ms 632 KB Output is correct
34 Correct 27 ms 888 KB Output is correct
35 Correct 24 ms 632 KB Output is correct
36 Correct 37 ms 1016 KB Output is correct
37 Correct 34 ms 888 KB Output is correct
38 Correct 28 ms 632 KB Output is correct
39 Correct 27 ms 632 KB Output is correct
40 Correct 27 ms 624 KB Output is correct
41 Correct 25 ms 888 KB Output is correct
42 Correct 28 ms 732 KB Output is correct