Submission #631270

# Submission time Handle Problem Language Result Execution time Memory
631270 2022-08-18T01:58:03 Z Hiennoob123 Brunhilda’s Birthday (BOI13_brunhilda) C++14
100 / 100
41 ms 4540 KB
#include<bits/stdc++.h>
#define ll long long
#define ld double
#define cd complex<ld>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std ;
ll m , q ;
ll A[100005] = {} ;
void solve()
{
    cin >> m >> q ;
    for(int i = 1 ; i<= m ; i++) cin >> A[i] ;
    vector<ll> ans ;
    ll cur = 0 ;
    ans.push_back(0) ;
    ll last = 0 ;
    while(cur<=10000000)
    {
        ll F = 0 ;
        for(int j = 1 ; j<= m ; j++)
        {
            F = max(F , cur-cur%A[j]+A[j]-1) ;
        }
        if(F<=cur) break ;
        ans.push_back(F) ;
        cur = F ;
        //cout << cur << "\n" ;
    }
    ans.push_back(10000000000) ;
    last = cur ;
    //for(int i = 0 ; i< ans.size() ; i++) cout << ans[i] << "\n" ;
    for(int i = 1 ; i<= q ; i++)
    {
        ll k ; cin >> k ;
        ll save = k ;
        if(save>last)
        {
            cout << "oo\n" ;
            continue ;
        }
        ll lo = 0 , hi = ans.size() ;
        hi-- ;
        if(hi<0)
        {
            cout << "oo\n" ;
            continue ;
        }
        while(hi-lo>1)
        {
            ll mid = ((hi+lo)>>1) ;
            if(ans[mid]>k) hi = mid ;
            else lo = mid ;
        }
        if(ans[lo]>=k)
        {
            cout << lo ;
        }
        else
        {
            cout << hi ;
        }
        cout << "\n" ;
    }
}
int main()
{
    ios_base::sync_with_stdio(NULL) ; cin.tie(nullptr) ; cout.tie(nullptr) ;
    //freopen("LINES.inp" , "r" , stdin) ;
    //freopen("LINES.out" , "w" , stdout) ;
    //freopen("IN.txt" , "r" , stdin) ;
    int t = 1; //cin >> t ;
    for(int i = 1 ; i<= t ; i++)
    {
        solve() ;
    }
}



# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 8 ms 676 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 4 ms 340 KB Output is correct
5 Correct 15 ms 2472 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 2 ms 984 KB Output is correct
9 Correct 25 ms 4540 KB Output is correct
10 Correct 14 ms 1492 KB Output is correct
11 Correct 15 ms 1420 KB Output is correct
12 Correct 3 ms 340 KB Output is correct
13 Correct 8 ms 344 KB Output is correct
14 Correct 9 ms 340 KB Output is correct
15 Correct 6 ms 696 KB Output is correct
16 Correct 9 ms 724 KB Output is correct
17 Correct 10 ms 724 KB Output is correct
18 Correct 3 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 9 ms 960 KB Output is correct
3 Correct 11 ms 980 KB Output is correct
4 Correct 3 ms 340 KB Output is correct
5 Correct 7 ms 724 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 3 ms 424 KB Output is correct
8 Correct 3 ms 340 KB Output is correct
9 Correct 9 ms 852 KB Output is correct
10 Correct 9 ms 852 KB Output is correct
11 Correct 8 ms 596 KB Output is correct
12 Correct 4 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 3 ms 340 KB Output is correct
15 Correct 6 ms 596 KB Output is correct
16 Correct 9 ms 980 KB Output is correct
17 Correct 7 ms 340 KB Output is correct
18 Correct 10 ms 1104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 724 KB Output is correct
2 Correct 11 ms 768 KB Output is correct
3 Correct 17 ms 852 KB Output is correct
4 Correct 17 ms 596 KB Output is correct
5 Correct 23 ms 1280 KB Output is correct
6 Correct 20 ms 560 KB Output is correct
7 Correct 21 ms 1108 KB Output is correct
8 Correct 14 ms 728 KB Output is correct
9 Correct 15 ms 724 KB Output is correct
10 Correct 6 ms 340 KB Output is correct
11 Correct 7 ms 340 KB Output is correct
12 Correct 8 ms 340 KB Output is correct
13 Correct 21 ms 768 KB Output is correct
14 Correct 41 ms 1652 KB Output is correct
15 Correct 9 ms 388 KB Output is correct
16 Correct 10 ms 340 KB Output is correct
17 Correct 9 ms 596 KB Output is correct
18 Correct 14 ms 732 KB Output is correct
19 Correct 5 ms 340 KB Output is correct
20 Correct 16 ms 796 KB Output is correct
21 Correct 29 ms 1100 KB Output is correct
22 Correct 25 ms 1240 KB Output is correct
23 Correct 23 ms 764 KB Output is correct
24 Correct 17 ms 616 KB Output is correct
25 Correct 21 ms 596 KB Output is correct
26 Correct 17 ms 596 KB Output is correct
27 Correct 20 ms 1120 KB Output is correct
28 Correct 19 ms 596 KB Output is correct
29 Correct 26 ms 1264 KB Output is correct
30 Correct 27 ms 1004 KB Output is correct
31 Correct 17 ms 488 KB Output is correct
32 Correct 19 ms 596 KB Output is correct
33 Correct 16 ms 596 KB Output is correct
34 Correct 21 ms 1108 KB Output is correct
35 Correct 18 ms 596 KB Output is correct
36 Correct 25 ms 1208 KB Output is correct
37 Correct 27 ms 1268 KB Output is correct
38 Correct 26 ms 596 KB Output is correct
39 Correct 25 ms 600 KB Output is correct
40 Correct 21 ms 724 KB Output is correct
41 Correct 17 ms 1108 KB Output is correct
42 Correct 27 ms 724 KB Output is correct