Submission #631267

# Submission time Handle Problem Language Result Execution time Memory
631267 2022-08-18T01:49:34 Z Hiennoob123 Brunhilda’s Birthday (BOI13_brunhilda) C++14
4.44444 / 100
62 ms 2512 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 ;
    }
    //for(int i = 0 ; i< ans.size() ; i++) cout << ans[i] << "\n" ;
    for(int i = 1 ; i<= q ; i++)
    {
        if(i>=100) assert(0) ;
        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 7 ms 852 KB Execution killed with signal 6
3 Incorrect 1 ms 340 KB Output isn't correct
4 Runtime error 2 ms 468 KB Execution killed with signal 6
5 Runtime error 16 ms 2120 KB Execution killed with signal 6
6 Runtime error 1 ms 468 KB Execution killed with signal 6
7 Incorrect 1 ms 340 KB Output isn't correct
8 Incorrect 2 ms 676 KB Output isn't correct
9 Incorrect 23 ms 2512 KB Output isn't correct
10 Runtime error 14 ms 1408 KB Execution killed with signal 6
11 Runtime error 14 ms 1364 KB Execution killed with signal 6
12 Runtime error 3 ms 468 KB Execution killed with signal 6
13 Runtime error 9 ms 468 KB Execution killed with signal 6
14 Runtime error 9 ms 464 KB Execution killed with signal 6
15 Runtime error 7 ms 980 KB Execution killed with signal 6
16 Runtime error 7 ms 852 KB Execution killed with signal 6
17 Runtime error 8 ms 836 KB Execution killed with signal 6
18 Runtime error 2 ms 468 KB Execution killed with signal 6
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Incorrect 9 ms 572 KB Output isn't correct
3 Incorrect 8 ms 596 KB Output isn't correct
4 Correct 3 ms 300 KB Output is correct
5 Incorrect 7 ms 468 KB Output isn't correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Incorrect 2 ms 340 KB Output isn't correct
8 Incorrect 3 ms 212 KB Output isn't correct
9 Incorrect 9 ms 596 KB Output isn't correct
10 Incorrect 9 ms 596 KB Output isn't correct
11 Incorrect 7 ms 372 KB Output isn't correct
12 Correct 3 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Incorrect 6 ms 492 KB Output isn't correct
16 Incorrect 8 ms 596 KB Output isn't correct
17 Incorrect 6 ms 340 KB Output isn't correct
18 Incorrect 10 ms 596 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Runtime error 30 ms 904 KB Execution killed with signal 6
2 Runtime error 33 ms 904 KB Execution killed with signal 6
3 Runtime error 31 ms 844 KB Execution killed with signal 6
4 Runtime error 5 ms 468 KB Execution killed with signal 6
5 Runtime error 55 ms 1220 KB Execution killed with signal 6
6 Runtime error 9 ms 468 KB Execution killed with signal 6
7 Runtime error 56 ms 1220 KB Execution killed with signal 6
8 Runtime error 30 ms 888 KB Execution killed with signal 6
9 Runtime error 30 ms 776 KB Execution killed with signal 6
10 Runtime error 7 ms 468 KB Execution killed with signal 6
11 Runtime error 5 ms 468 KB Execution killed with signal 6
12 Runtime error 7 ms 468 KB Execution killed with signal 6
13 Runtime error 21 ms 668 KB Execution killed with signal 6
14 Runtime error 21 ms 1448 KB Execution killed with signal 6
15 Runtime error 8 ms 476 KB Execution killed with signal 6
16 Runtime error 10 ms 496 KB Execution killed with signal 6
17 Runtime error 30 ms 752 KB Execution killed with signal 6
18 Runtime error 33 ms 844 KB Execution killed with signal 6
19 Runtime error 4 ms 468 KB Execution killed with signal 6
20 Runtime error 34 ms 768 KB Execution killed with signal 6
21 Runtime error 9 ms 644 KB Execution killed with signal 6
22 Runtime error 57 ms 1220 KB Execution killed with signal 6
23 Runtime error 18 ms 724 KB Execution killed with signal 6
24 Runtime error 2 ms 468 KB Execution killed with signal 6
25 Runtime error 6 ms 468 KB Execution killed with signal 6
26 Runtime error 5 ms 468 KB Execution killed with signal 6
27 Runtime error 59 ms 1224 KB Execution killed with signal 6
28 Runtime error 2 ms 468 KB Execution killed with signal 6
29 Runtime error 62 ms 1236 KB Execution killed with signal 6
30 Runtime error 43 ms 976 KB Execution killed with signal 6
31 Runtime error 4 ms 468 KB Execution killed with signal 6
32 Runtime error 4 ms 468 KB Execution killed with signal 6
33 Runtime error 2 ms 468 KB Execution killed with signal 6
34 Runtime error 59 ms 1204 KB Execution killed with signal 6
35 Runtime error 3 ms 468 KB Execution killed with signal 6
36 Runtime error 52 ms 1184 KB Execution killed with signal 6
37 Runtime error 55 ms 1236 KB Execution killed with signal 6
38 Runtime error 9 ms 468 KB Execution killed with signal 6
39 Runtime error 3 ms 468 KB Execution killed with signal 6
40 Runtime error 8 ms 492 KB Execution killed with signal 6
41 Runtime error 54 ms 1264 KB Execution killed with signal 6
42 Runtime error 8 ms 468 KB Execution killed with signal 6