Submission #856575

# Submission time Handle Problem Language Result Execution time Memory
856575 2023-10-04T02:11:36 Z ngjabach Brunhilda’s Birthday (BOI13_brunhilda) C++14
100 / 100
222 ms 47956 KB
// NgJaBach: Forever Meadow <3

#include<bits/stdc++.h>

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long int ll;
typedef unsigned long long ull;
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define bend(a) a.begin(),a.end()
#define rev(x) reverse(bend(x))
#define mset(a) memset(a, 0, sizeof(a))
#define fi first
#define se second
#define gcd __gcd
#define getl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
#define endl '\n'
const int N=12000000,M=1000000000;
const ll INF=1e18+7;
int dp[N+50];
int main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
//    freopen(".inp","r",stdin);
//    freopen(".out","w",stdout);
    int n,q,a;
    cin>>n>>q;
    mset(dp);
    while(n--){
        cin>>a;
        for(int i=a-1;i<=N;i+=a) dp[i]=max(dp[i],a-1);
    }
    for(int i=N;i>0;--i) dp[i]=max(dp[i],dp[i+1]-1);
    for(int i=1;i<=N;++i){
        if(dp[i]>0) dp[i]=dp[i-dp[i]]+1;
        else dp[i]=M;
    }
    while(q--){
        cin>>a;
        if(dp[a]>=M) cout<<"oo";
        else cout<<dp[a];
        cout<<endl;
    }
    return 0;
}
/*
==================================+
INPUT:                            |
------------------------------    |
2 2
2 3
5
6

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/
# Verdict Execution time Memory Grader output
1 Correct 64 ms 47192 KB Output is correct
2 Correct 77 ms 47196 KB Output is correct
3 Correct 71 ms 47404 KB Output is correct
4 Correct 62 ms 47196 KB Output is correct
5 Correct 72 ms 47196 KB Output is correct
6 Correct 64 ms 47408 KB Output is correct
7 Correct 75 ms 47196 KB Output is correct
8 Correct 74 ms 47192 KB Output is correct
9 Correct 85 ms 47196 KB Output is correct
10 Correct 104 ms 47416 KB Output is correct
11 Correct 92 ms 47192 KB Output is correct
12 Correct 60 ms 47192 KB Output is correct
13 Correct 157 ms 47196 KB Output is correct
14 Correct 144 ms 47420 KB Output is correct
15 Correct 82 ms 47396 KB Output is correct
16 Correct 77 ms 47192 KB Output is correct
17 Correct 75 ms 47404 KB Output is correct
18 Correct 62 ms 47192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 70 ms 47404 KB Output is correct
2 Correct 85 ms 47196 KB Output is correct
3 Correct 205 ms 47196 KB Output is correct
4 Correct 86 ms 47404 KB Output is correct
5 Correct 127 ms 47404 KB Output is correct
6 Correct 79 ms 47192 KB Output is correct
7 Correct 69 ms 47192 KB Output is correct
8 Correct 82 ms 47404 KB Output is correct
9 Correct 147 ms 47400 KB Output is correct
10 Correct 189 ms 47192 KB Output is correct
11 Correct 169 ms 47440 KB Output is correct
12 Correct 100 ms 47440 KB Output is correct
13 Correct 71 ms 47192 KB Output is correct
14 Correct 84 ms 47196 KB Output is correct
15 Correct 149 ms 47404 KB Output is correct
16 Correct 86 ms 47192 KB Output is correct
17 Correct 143 ms 47404 KB Output is correct
18 Correct 150 ms 47448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 149 ms 47404 KB Output is correct
2 Correct 192 ms 47400 KB Output is correct
3 Correct 179 ms 47444 KB Output is correct
4 Correct 124 ms 47420 KB Output is correct
5 Correct 103 ms 47400 KB Output is correct
6 Correct 163 ms 47660 KB Output is correct
7 Correct 139 ms 47444 KB Output is correct
8 Correct 161 ms 47400 KB Output is correct
9 Correct 152 ms 47444 KB Output is correct
10 Correct 124 ms 47196 KB Output is correct
11 Correct 105 ms 47404 KB Output is correct
12 Correct 136 ms 47444 KB Output is correct
13 Correct 177 ms 47444 KB Output is correct
14 Correct 115 ms 47956 KB Output is correct
15 Correct 140 ms 47448 KB Output is correct
16 Correct 154 ms 47416 KB Output is correct
17 Correct 155 ms 47440 KB Output is correct
18 Correct 175 ms 47440 KB Output is correct
19 Correct 74 ms 47444 KB Output is correct
20 Correct 182 ms 47440 KB Output is correct
21 Correct 128 ms 47952 KB Output is correct
22 Correct 202 ms 47408 KB Output is correct
23 Correct 98 ms 47404 KB Output is correct
24 Correct 96 ms 47824 KB Output is correct
25 Correct 130 ms 47664 KB Output is correct
26 Correct 123 ms 47656 KB Output is correct
27 Correct 222 ms 47400 KB Output is correct
28 Correct 96 ms 47680 KB Output is correct
29 Correct 177 ms 47496 KB Output is correct
30 Correct 161 ms 47408 KB Output is correct
31 Correct 98 ms 47408 KB Output is correct
32 Correct 111 ms 47672 KB Output is correct
33 Correct 82 ms 47444 KB Output is correct
34 Correct 147 ms 47416 KB Output is correct
35 Correct 87 ms 47656 KB Output is correct
36 Correct 191 ms 47552 KB Output is correct
37 Correct 105 ms 47412 KB Output is correct
38 Correct 163 ms 47660 KB Output is correct
39 Correct 92 ms 47556 KB Output is correct
40 Correct 134 ms 47448 KB Output is correct
41 Correct 137 ms 47444 KB Output is correct
42 Correct 168 ms 47700 KB Output is correct