답안 #503301

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
503301 2022-01-07T15:52:40 Z Lobo Brunhilda’s Birthday (BOI13_brunhilda) C++17
100 / 100
483 ms 4504 KB
#include<bits/stdc++.h>
using namespace std;

const long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
#define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()

#define maxn 110000
#define mxv 10000000

int m, q, p[maxn];

void solve() {
    cin >> m >> q;

    int lc = 1;
    for(int i = 1; i <= m; i++) {
        cin >> p[i];
        lc = lc*p[i];
        lc = min(lc, (int) mxv+1);
    }

    vector<int> d;
    //d[0] = 0;
    d.pb(0);
    int act = 1;
    while(act < lc) {
        int l = act;
        int r = mxv;
        int ans = act;
        while(l <= r) {
            int mid = (l+r)/2;

            bool ok = false;
            for(int i = 1; i <= m; i++) {
                if(mid - mid%p[i] < act) ok = true;
            }

            if(ok) {
                l = mid+1;
                ans = mid;
            }
            else
                r = mid-1;
        }

        d.pb(ans);
        act = ans+1;
    }


    // for(auto x : d) {
    //     cout << x << endl;
    // }

    for(int i = 1; i <= q; i++) {
        int x; cin >> x;
        auto it = lower_bound(all(d),x);
        if(it == d.end()) {
            cout << "oo" << endl;
        }
        else 
            cout << it-d.begin() << endl;
    }    

}

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(0);

    // freopen("in.in", "r", stdin);
    //freopen("out.out", "w", stdout);

    int tt = 1;
    // cin >> tt;
    while(tt--) solve();

}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 142 ms 632 KB Output is correct
3 Correct 10 ms 448 KB Output is correct
4 Correct 35 ms 388 KB Output is correct
5 Correct 277 ms 2616 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 10 ms 444 KB Output is correct
8 Correct 35 ms 840 KB Output is correct
9 Correct 483 ms 4504 KB Output is correct
10 Correct 317 ms 1384 KB Output is correct
11 Correct 292 ms 1372 KB Output is correct
12 Correct 55 ms 320 KB Output is correct
13 Correct 165 ms 340 KB Output is correct
14 Correct 166 ms 380 KB Output is correct
15 Correct 125 ms 672 KB Output is correct
16 Correct 145 ms 608 KB Output is correct
17 Correct 169 ms 732 KB Output is correct
18 Correct 36 ms 372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 436 KB Output is correct
2 Correct 31 ms 1628 KB Output is correct
3 Correct 72 ms 1328 KB Output is correct
4 Correct 43 ms 348 KB Output is correct
5 Correct 51 ms 976 KB Output is correct
6 Correct 21 ms 336 KB Output is correct
7 Correct 19 ms 492 KB Output is correct
8 Correct 50 ms 332 KB Output is correct
9 Correct 72 ms 1356 KB Output is correct
10 Correct 68 ms 1228 KB Output is correct
11 Correct 91 ms 964 KB Output is correct
12 Correct 56 ms 332 KB Output is correct
13 Correct 9 ms 332 KB Output is correct
14 Correct 43 ms 344 KB Output is correct
15 Correct 70 ms 908 KB Output is correct
16 Correct 28 ms 1680 KB Output is correct
17 Correct 117 ms 348 KB Output is correct
18 Correct 51 ms 1856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 1316 KB Output is correct
2 Correct 101 ms 1220 KB Output is correct
3 Correct 107 ms 1572 KB Output is correct
4 Correct 66 ms 1272 KB Output is correct
5 Correct 61 ms 2720 KB Output is correct
6 Correct 100 ms 1372 KB Output is correct
7 Correct 77 ms 2344 KB Output is correct
8 Correct 73 ms 1348 KB Output is correct
9 Correct 79 ms 1316 KB Output is correct
10 Correct 77 ms 448 KB Output is correct
11 Correct 63 ms 576 KB Output is correct
12 Correct 83 ms 600 KB Output is correct
13 Correct 105 ms 1664 KB Output is correct
14 Correct 434 ms 2460 KB Output is correct
15 Correct 96 ms 616 KB Output is correct
16 Correct 117 ms 560 KB Output is correct
17 Correct 75 ms 1092 KB Output is correct
18 Correct 102 ms 1204 KB Output is correct
19 Correct 15 ms 604 KB Output is correct
20 Correct 108 ms 1572 KB Output is correct
21 Correct 207 ms 1824 KB Output is correct
22 Correct 107 ms 2732 KB Output is correct
23 Correct 57 ms 1680 KB Output is correct
24 Correct 34 ms 1340 KB Output is correct
25 Correct 100 ms 1344 KB Output is correct
26 Correct 62 ms 1212 KB Output is correct
27 Correct 110 ms 2244 KB Output is correct
28 Correct 30 ms 1392 KB Output is correct
29 Correct 108 ms 2756 KB Output is correct
30 Correct 109 ms 2256 KB Output is correct
31 Correct 36 ms 1240 KB Output is correct
32 Correct 63 ms 1244 KB Output is correct
33 Correct 25 ms 1184 KB Output is correct
34 Correct 74 ms 2340 KB Output is correct
35 Correct 41 ms 1364 KB Output is correct
36 Correct 95 ms 2508 KB Output is correct
37 Correct 58 ms 2756 KB Output is correct
38 Correct 106 ms 1400 KB Output is correct
39 Correct 44 ms 1336 KB Output is correct
40 Correct 75 ms 1384 KB Output is correct
41 Correct 51 ms 2240 KB Output is correct
42 Correct 139 ms 1456 KB Output is correct