Submission #305843

# Submission time Handle Problem Language Result Execution time Memory
305843 2020-09-24T02:34:49 Z HynDuf Brunhilda’s Birthday (BOI13_brunhilda) C++11
100 / 100
337 ms 41720 KB
#include <bits/stdc++.h>

#define task "B"
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define DB(X) { cerr << #X << " = " << (X) << '\n'; }
#define DB1(A, _) { cerr << #A << "[" << _ << "] = " << (A[_]) << '\n'; }
#define DB2(A, _, __) { cerr << #A << "[" << _ << "][" << __ << "] = " << (A[_][__]) << '\n'; }
#define DB3(A, _, __, ___) { cerr << #A << "[" << _ << "][" << __ << "][" << ___ << "] = " << (A[_][__][___]) << '\n'; }
#define PR(A, l, r) { cerr << '\n'; rep(_, l, r) DB1(A, _); cerr << '\n';}
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define pf push_front
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));
#define next ___next
#define prev ___prev
#define y1 ___y1
#define left ___left
#define right ___right
#define y0 ___y0
#define div ___div
#define j0 ___j0
#define jn ___jn

using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;
const int N = 1e5 + 2, NN = 1e7 + 1e5;
int n, q, dp[NN + 2];
int main()
{
#ifdef HynDuf
    freopen(task".in", "r", stdin);
    //freopen(task".out", "w", stdout);
#else
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif
    cin >> n >> q;
    ll lcm = 1;
    rep(i, 1, n)
    {
        int p;
        cin >> p;
        for (int j = p - 1; j <= NN; j += p) dp[j] = p - 1;
        lcm = min(N * 100LL, lcm * p);
    }
    Rep(i, NN - 1, 1) dp[i] = max(dp[i], dp[i + 1] - 1);
    rep(i, 1, NN) dp[i] = dp[i - dp[i]] + 1;
    while (q--)
    {
        int x;
        cin >> x;
        if (x >= lcm) cout << "oo\n";
        else cout << dp[x] << '\n';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 94 ms 39808 KB Output is correct
2 Correct 122 ms 39808 KB Output is correct
3 Correct 102 ms 39928 KB Output is correct
4 Correct 84 ms 39928 KB Output is correct
5 Correct 102 ms 39912 KB Output is correct
6 Correct 86 ms 39808 KB Output is correct
7 Correct 96 ms 39808 KB Output is correct
8 Correct 99 ms 39808 KB Output is correct
9 Correct 117 ms 39808 KB Output is correct
10 Correct 142 ms 39840 KB Output is correct
11 Correct 127 ms 39840 KB Output is correct
12 Correct 86 ms 39916 KB Output is correct
13 Correct 231 ms 39808 KB Output is correct
14 Correct 242 ms 39928 KB Output is correct
15 Correct 116 ms 39800 KB Output is correct
16 Correct 107 ms 39808 KB Output is correct
17 Correct 109 ms 40056 KB Output is correct
18 Correct 88 ms 39928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 103 ms 39988 KB Output is correct
2 Correct 124 ms 40568 KB Output is correct
3 Correct 309 ms 40312 KB Output is correct
4 Correct 127 ms 39928 KB Output is correct
5 Correct 203 ms 40184 KB Output is correct
6 Correct 105 ms 39920 KB Output is correct
7 Correct 107 ms 39888 KB Output is correct
8 Correct 123 ms 39912 KB Output is correct
9 Correct 245 ms 40312 KB Output is correct
10 Correct 291 ms 40428 KB Output is correct
11 Correct 284 ms 40056 KB Output is correct
12 Correct 166 ms 39808 KB Output is correct
13 Correct 95 ms 39928 KB Output is correct
14 Correct 122 ms 39808 KB Output is correct
15 Correct 239 ms 40176 KB Output is correct
16 Correct 124 ms 40568 KB Output is correct
17 Correct 249 ms 39924 KB Output is correct
18 Correct 258 ms 40556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 258 ms 40700 KB Output is correct
2 Correct 304 ms 40440 KB Output is correct
3 Correct 324 ms 40824 KB Output is correct
4 Correct 195 ms 40824 KB Output is correct
5 Correct 162 ms 41720 KB Output is correct
6 Correct 271 ms 40824 KB Output is correct
7 Correct 229 ms 41080 KB Output is correct
8 Correct 262 ms 40568 KB Output is correct
9 Correct 253 ms 40696 KB Output is correct
10 Correct 201 ms 40056 KB Output is correct
11 Correct 172 ms 40056 KB Output is correct
12 Correct 227 ms 40184 KB Output is correct
13 Correct 299 ms 41080 KB Output is correct
14 Correct 173 ms 40440 KB Output is correct
15 Correct 230 ms 40216 KB Output is correct
16 Correct 266 ms 40184 KB Output is correct
17 Correct 241 ms 40312 KB Output is correct
18 Correct 308 ms 40428 KB Output is correct
19 Correct 101 ms 40056 KB Output is correct
20 Correct 300 ms 40824 KB Output is correct
21 Correct 192 ms 40440 KB Output is correct
22 Correct 321 ms 41592 KB Output is correct
23 Correct 156 ms 41080 KB Output is correct
24 Correct 125 ms 40824 KB Output is correct
25 Correct 208 ms 40952 KB Output is correct
26 Correct 192 ms 40824 KB Output is correct
27 Correct 337 ms 41068 KB Output is correct
28 Correct 122 ms 40952 KB Output is correct
29 Correct 307 ms 41580 KB Output is correct
30 Correct 266 ms 41324 KB Output is correct
31 Correct 143 ms 40824 KB Output is correct
32 Correct 166 ms 40824 KB Output is correct
33 Correct 119 ms 40824 KB Output is correct
34 Correct 227 ms 41084 KB Output is correct
35 Correct 126 ms 41080 KB Output is correct
36 Correct 319 ms 41464 KB Output is correct
37 Correct 153 ms 41592 KB Output is correct
38 Correct 254 ms 40952 KB Output is correct
39 Correct 136 ms 40972 KB Output is correct
40 Correct 216 ms 40824 KB Output is correct
41 Correct 201 ms 41208 KB Output is correct
42 Correct 275 ms 41208 KB Output is correct