Submission #631266

# Submission time Handle Problem Language Result Execution time Memory
631266 2022-08-18T01:48:23 Z Hiennoob123 Brunhilda’s Birthday (BOI13_brunhilda) C++14
0 / 100
26 ms 2912 KB
#include<bits/stdc++.h>
#define ll int
#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) ;
    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 ;
    }
    assert(0) ;
    //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 ;
        for(int j = 1 ; j<= m ; j++) save /= A[j] ;
        if(save>0)
        {
            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[hi]<=k)
        {
            cout << hi ;
        }
        else cout << lo ;
        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 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Runtime error 8 ms 960 KB Execution killed with signal 6
3 Runtime error 1 ms 724 KB Execution killed with signal 6
4 Runtime error 2 ms 468 KB Execution killed with signal 6
5 Runtime error 15 ms 2000 KB Execution killed with signal 6
6 Runtime error 1 ms 468 KB Execution killed with signal 6
7 Runtime error 1 ms 724 KB Execution killed with signal 6
8 Runtime error 3 ms 984 KB Execution killed with signal 6
9 Runtime error 26 ms 2912 KB Execution killed with signal 6
10 Runtime error 14 ms 1476 KB Execution killed with signal 6
11 Runtime error 15 ms 1368 KB Execution killed with signal 6
12 Runtime error 3 ms 536 KB Execution killed with signal 6
13 Runtime error 8 ms 468 KB Execution killed with signal 6
14 Runtime error 8 ms 468 KB Execution killed with signal 6
15 Runtime error 7 ms 980 KB Execution killed with signal 6
16 Runtime error 8 ms 852 KB Execution killed with signal 6
17 Runtime error 10 ms 852 KB Execution killed with signal 6
18 Runtime error 3 ms 468 KB Execution killed with signal 6
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 596 KB Execution killed with signal 6
2 Runtime error 12 ms 1236 KB Execution killed with signal 6
3 Runtime error 10 ms 980 KB Execution killed with signal 6
4 Runtime error 3 ms 468 KB Execution killed with signal 6
5 Runtime error 7 ms 852 KB Execution killed with signal 6
6 Runtime error 2 ms 468 KB Execution killed with signal 6
7 Runtime error 3 ms 596 KB Execution killed with signal 6
8 Runtime error 3 ms 468 KB Execution killed with signal 6
9 Runtime error 10 ms 980 KB Execution killed with signal 6
10 Runtime error 8 ms 980 KB Execution killed with signal 6
11 Runtime error 7 ms 724 KB Execution killed with signal 6
12 Runtime error 4 ms 468 KB Execution killed with signal 6
13 Runtime error 1 ms 468 KB Execution killed with signal 6
14 Runtime error 3 ms 468 KB Execution killed with signal 6
15 Runtime error 8 ms 852 KB Execution killed with signal 6
16 Runtime error 9 ms 1164 KB Execution killed with signal 6
17 Runtime error 7 ms 472 KB Execution killed with signal 6
18 Runtime error 10 ms 1216 KB Execution killed with signal 6
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 912 KB Execution killed with signal 6
2 Runtime error 9 ms 868 KB Execution killed with signal 6
3 Runtime error 9 ms 852 KB Execution killed with signal 6
4 Runtime error 4 ms 468 KB Execution killed with signal 6
5 Runtime error 10 ms 1236 KB Execution killed with signal 6
6 Runtime error 5 ms 488 KB Execution killed with signal 6
7 Runtime error 11 ms 1236 KB Execution killed with signal 6
8 Runtime error 10 ms 852 KB Execution killed with signal 6
9 Runtime error 9 ms 792 KB Execution killed with signal 6
10 Runtime error 6 ms 468 KB Execution killed with signal 6
11 Runtime error 4 ms 468 KB Execution killed with signal 6
12 Runtime error 5 ms 468 KB Execution killed with signal 6
13 Runtime error 7 ms 724 KB Execution killed with signal 6
14 Runtime error 20 ms 1416 KB Execution killed with signal 6
15 Runtime error 5 ms 468 KB Execution killed with signal 6
16 Runtime error 6 ms 468 KB Execution killed with signal 6
17 Runtime error 7 ms 852 KB Execution killed with signal 6
18 Runtime error 9 ms 852 KB Execution killed with signal 6
19 Runtime error 1 ms 468 KB Execution killed with signal 6
20 Runtime error 10 ms 852 KB Execution killed with signal 6
21 Runtime error 9 ms 644 KB Execution killed with signal 6
22 Runtime error 12 ms 1236 KB Execution killed with signal 6
23 Runtime error 5 ms 724 KB Execution killed with signal 6
24 Runtime error 1 ms 468 KB Execution killed with signal 6
25 Runtime error 5 ms 468 KB Execution killed with signal 6
26 Runtime error 4 ms 468 KB Execution killed with signal 6
27 Runtime error 12 ms 1292 KB Execution killed with signal 6
28 Runtime error 1 ms 468 KB Execution killed with signal 6
29 Runtime error 16 ms 1236 KB Execution killed with signal 6
30 Runtime error 12 ms 976 KB Execution killed with signal 6
31 Runtime error 3 ms 468 KB Execution killed with signal 6
32 Runtime error 3 ms 468 KB Execution killed with signal 6
33 Runtime error 1 ms 468 KB Execution killed with signal 6
34 Runtime error 10 ms 1228 KB Execution killed with signal 6
35 Runtime error 2 ms 468 KB Execution killed with signal 6
36 Runtime error 11 ms 1108 KB Execution killed with signal 6
37 Runtime error 10 ms 1236 KB Execution killed with signal 6
38 Runtime error 5 ms 468 KB Execution killed with signal 6
39 Runtime error 3 ms 468 KB Execution killed with signal 6
40 Runtime error 4 ms 468 KB Execution killed with signal 6
41 Runtime error 11 ms 1200 KB Execution killed with signal 6
42 Runtime error 7 ms 468 KB Execution killed with signal 6