답안 #631269

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
631269 2022-08-18T01:51:41 Z Hiennoob123 Brunhilda’s Birthday (BOI13_brunhilda) C++14
4.44444 / 100
40 ms 2452 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) ;
    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 ;
    }
    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[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() ;
    }
}



# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Incorrect 7 ms 468 KB Output isn't correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Incorrect 4 ms 340 KB Output isn't correct
5 Incorrect 14 ms 1460 KB Output isn't correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Incorrect 1 ms 340 KB Output isn't correct
8 Incorrect 2 ms 724 KB Output isn't correct
9 Incorrect 24 ms 2452 KB Output isn't correct
10 Incorrect 15 ms 984 KB Output isn't correct
11 Incorrect 15 ms 984 KB Output isn't correct
12 Incorrect 3 ms 340 KB Output isn't correct
13 Incorrect 8 ms 340 KB Output isn't correct
14 Incorrect 9 ms 340 KB Output isn't correct
15 Incorrect 7 ms 468 KB Output isn't correct
16 Incorrect 7 ms 468 KB Output isn't correct
17 Incorrect 11 ms 468 KB Output isn't correct
18 Incorrect 4 ms 340 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Incorrect 9 ms 596 KB Output isn't correct
3 Incorrect 10 ms 596 KB Output isn't correct
4 Correct 2 ms 340 KB Output is correct
5 Incorrect 6 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 2 ms 212 KB Output isn't correct
9 Incorrect 8 ms 596 KB Output isn't correct
10 Incorrect 8 ms 596 KB Output isn't correct
11 Incorrect 7 ms 484 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 3 ms 212 KB Output is correct
15 Incorrect 7 ms 468 KB Output isn't correct
16 Incorrect 11 ms 592 KB Output isn't correct
17 Incorrect 6 ms 340 KB Output isn't correct
18 Incorrect 10 ms 624 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 596 KB Output isn't correct
2 Incorrect 12 ms 468 KB Output isn't correct
3 Incorrect 18 ms 596 KB Output isn't correct
4 Incorrect 19 ms 592 KB Output isn't correct
5 Incorrect 23 ms 880 KB Output isn't correct
6 Incorrect 20 ms 488 KB Output isn't correct
7 Incorrect 19 ms 776 KB Output isn't correct
8 Incorrect 13 ms 516 KB Output isn't correct
9 Incorrect 14 ms 592 KB Output isn't correct
10 Incorrect 6 ms 340 KB Output isn't correct
11 Incorrect 9 ms 468 KB Output isn't correct
12 Incorrect 9 ms 372 KB Output isn't correct
13 Incorrect 21 ms 668 KB Output isn't correct
14 Incorrect 40 ms 1328 KB Output isn't correct
15 Incorrect 11 ms 340 KB Output isn't correct
16 Incorrect 9 ms 340 KB Output isn't correct
17 Incorrect 9 ms 448 KB Output isn't correct
18 Incorrect 12 ms 596 KB Output isn't correct
19 Incorrect 5 ms 360 KB Output isn't correct
20 Incorrect 17 ms 636 KB Output isn't correct
21 Incorrect 36 ms 1024 KB Output isn't correct
22 Incorrect 29 ms 880 KB Output isn't correct
23 Incorrect 26 ms 612 KB Output isn't correct
24 Incorrect 19 ms 596 KB Output isn't correct
25 Incorrect 21 ms 616 KB Output isn't correct
26 Incorrect 18 ms 508 KB Output isn't correct
27 Incorrect 21 ms 776 KB Output isn't correct
28 Incorrect 20 ms 632 KB Output isn't correct
29 Incorrect 27 ms 852 KB Output isn't correct
30 Incorrect 26 ms 716 KB Output isn't correct
31 Incorrect 20 ms 532 KB Output isn't correct
32 Incorrect 18 ms 584 KB Output isn't correct
33 Incorrect 16 ms 576 KB Output isn't correct
34 Incorrect 18 ms 776 KB Output isn't correct
35 Incorrect 18 ms 596 KB Output isn't correct
36 Incorrect 25 ms 752 KB Output isn't correct
37 Incorrect 24 ms 852 KB Output isn't correct
38 Incorrect 20 ms 540 KB Output isn't correct
39 Incorrect 19 ms 596 KB Output isn't correct
40 Incorrect 20 ms 592 KB Output isn't correct
41 Incorrect 17 ms 716 KB Output isn't correct
42 Incorrect 24 ms 728 KB Output isn't correct