Submission #923640

# Submission time Handle Problem Language Result Execution time Memory
923640 2024-02-07T14:08:15 Z sleepntsheep Brunhilda’s Birthday (BOI13_brunhilda) C++17
0 / 100
1000 ms 4700 KB
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <cstring>
#include <vector>
#include <algorithm>
#include <deque>
#include <set>
#include <utility>
#include <array>
#include <complex>

using u32 = unsigned;
using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;

using namespace std;

#define ALL(x) begin(x), end(x)
#define ShinLena cin.tie(nullptr)->sync_with_stdio(false);

#if 0
#define M 100005
#define N 10000005
#else
#define M 20000
#define N 20000
#endif

int m, q, dp[N], p[M];

multiset<int> ms;
basic_string<int> act[N], fus[N];

int main()
{
    memset(dp, 63, sizeof dp);
    ShinLena;

    dp[0] = 0;
    cin >> m >> q;
    for (int i = 1; i <= m; ++i)
    {
        cin >> p[i];
        act[1].push_back(1);
        act[p[i]].push_back(-1);
        for (int j = p[i]; j < N; j += p[i]) fus[j].push_back(p[i]);
    }

    for (int i = 1; i <= N; ++i)
    {
        for (auto x : act[i])
        {
            if (x < 0) ms.erase(ms.find(-x - 1));
            else ms.insert(x - 1);
        }

        dp[i] = min(dp[i], *ms.begin()  + 1);

        for (auto x : fus[i])
        {
            act[i+1].push_back(dp[i] + 1);
            act[x+i].push_back(-dp[i] - 1);
        }
    }

    for (int x, i = 1; i <= q; ++i)
    {
        cin >> x;
        if (dp[x] > 1e9) cout << "oo\n";
        else cout << dp[x] << '\n';
    }


    return 0;
}


# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 3416 KB Execution killed with signal 6
2 Runtime error 4 ms 3324 KB Execution killed with signal 11
3 Runtime error 3 ms 3080 KB Execution killed with signal 11
4 Runtime error 4 ms 3420 KB Execution killed with signal 6
5 Runtime error 2 ms 3164 KB Execution killed with signal 11
6 Runtime error 4 ms 3420 KB Execution killed with signal 6
7 Runtime error 3 ms 3164 KB Execution killed with signal 11
8 Runtime error 3 ms 3420 KB Execution killed with signal 11
9 Runtime error 5 ms 3676 KB Execution killed with signal 11
10 Runtime error 5 ms 3928 KB Execution killed with signal 11
11 Runtime error 4 ms 3420 KB Execution killed with signal 11
12 Runtime error 2 ms 3164 KB Execution killed with signal 11
13 Runtime error 7 ms 4700 KB Execution killed with signal 11
14 Runtime error 7 ms 4616 KB Execution killed with signal 11
15 Execution timed out 1076 ms 1628 KB Time limit exceeded
16 Runtime error 4 ms 3164 KB Execution killed with signal 11
17 Runtime error 3 ms 3164 KB Execution killed with signal 11
18 Runtime error 4 ms 3416 KB Execution killed with signal 6
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 3164 KB Execution killed with signal 11
2 Runtime error 2 ms 3112 KB Execution killed with signal 11
3 Runtime error 3 ms 3416 KB Execution killed with signal 11
4 Runtime error 2 ms 3164 KB Execution killed with signal 11
5 Runtime error 2 ms 3164 KB Execution killed with signal 11
6 Runtime error 3 ms 3164 KB Execution killed with signal 11
7 Runtime error 2 ms 3340 KB Execution killed with signal 11
8 Runtime error 2 ms 3416 KB Execution killed with signal 11
9 Runtime error 2 ms 3164 KB Execution killed with signal 11
10 Runtime error 3 ms 3600 KB Execution killed with signal 11
11 Runtime error 2 ms 3428 KB Execution killed with signal 11
12 Runtime error 2 ms 3416 KB Execution killed with signal 11
13 Runtime error 3 ms 3416 KB Execution killed with signal 6
14 Runtime error 3 ms 3164 KB Execution killed with signal 11
15 Runtime error 3 ms 3408 KB Execution killed with signal 11
16 Runtime error 3 ms 3164 KB Execution killed with signal 11
17 Runtime error 2 ms 3672 KB Execution killed with signal 11
18 Runtime error 2 ms 3420 KB Execution killed with signal 11
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 3420 KB Execution killed with signal 11
2 Runtime error 3 ms 3416 KB Execution killed with signal 11
3 Runtime error 2 ms 3416 KB Execution killed with signal 11
4 Runtime error 3 ms 3164 KB Execution killed with signal 11
5 Runtime error 2 ms 3164 KB Execution killed with signal 11
6 Runtime error 3 ms 3164 KB Execution killed with signal 11
7 Runtime error 2 ms 3164 KB Execution killed with signal 11
8 Runtime error 2 ms 3432 KB Execution killed with signal 11
9 Runtime error 2 ms 3232 KB Execution killed with signal 11
10 Runtime error 2 ms 3164 KB Execution killed with signal 11
11 Runtime error 2 ms 3344 KB Execution killed with signal 11
12 Runtime error 2 ms 3416 KB Execution killed with signal 11
13 Runtime error 3 ms 3420 KB Execution killed with signal 11
14 Execution timed out 1094 ms 2120 KB Time limit exceeded
15 Runtime error 3 ms 3420 KB Execution killed with signal 11
16 Runtime error 2 ms 3420 KB Execution killed with signal 11
17 Runtime error 2 ms 3416 KB Execution killed with signal 11
18 Runtime error 3 ms 3420 KB Execution killed with signal 11
19 Runtime error 3 ms 3420 KB Execution killed with signal 6
20 Runtime error 3 ms 3420 KB Execution killed with signal 11
21 Runtime error 7 ms 4696 KB Execution killed with signal 11
22 Runtime error 3 ms 3420 KB Execution killed with signal 11
23 Runtime error 2 ms 3164 KB Execution killed with signal 11
24 Runtime error 3 ms 3420 KB Execution killed with signal 6
25 Runtime error 2 ms 3164 KB Execution killed with signal 11
26 Runtime error 3 ms 3344 KB Execution killed with signal 11
27 Runtime error 3 ms 3420 KB Execution killed with signal 11
28 Runtime error 2 ms 3164 KB Execution killed with signal 11
29 Runtime error 2 ms 3420 KB Execution killed with signal 11
30 Runtime error 2 ms 3416 KB Execution killed with signal 11
31 Runtime error 3 ms 3164 KB Execution killed with signal 11
32 Runtime error 2 ms 3160 KB Execution killed with signal 11
33 Runtime error 3 ms 3416 KB Execution killed with signal 6
34 Runtime error 2 ms 3164 KB Execution killed with signal 11
35 Runtime error 3 ms 3620 KB Execution killed with signal 6
36 Runtime error 2 ms 3420 KB Execution killed with signal 11
37 Runtime error 3 ms 3420 KB Execution killed with signal 11
38 Runtime error 2 ms 3164 KB Execution killed with signal 11
39 Runtime error 3 ms 3420 KB Execution killed with signal 6
40 Runtime error 2 ms 3164 KB Execution killed with signal 11
41 Runtime error 2 ms 3344 KB Execution killed with signal 11
42 Runtime error 3 ms 3420 KB Execution killed with signal 11