Submission #742842

# Submission time Handle Problem Language Result Execution time Memory
742842 2023-05-17T03:51:11 Z irmuun Brunhilda’s Birthday (BOI13_brunhilda) C++17
100 / 100
550 ms 157572 KB
#include<bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define all(s) s.begin(),s.end()

const int MAX=2e7+5;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int m,q;
    cin>>m>>q;
    int p[m+5];
    for(int i=1;i<=m;i++){
        cin>>p[i];
    }
    vector<int>mn(MAX,MAX);
    for(int i=1;i<=m;i++){
        for(int k=0;(k+1)*p[i]<MAX;k++){
            mn[(k+1)*p[i]-1]=min(mn[(k+1)*p[i]-1],k*p[i]);
        }
    }
    for(int i=MAX-2;i>=0;i--){
        mn[i]=min(mn[i],mn[i+1]);
    }
    vector<int>ans(MAX);
    for(int i=1;i<MAX;i++){
        if(mn[i]==i||mn[i]==MAX){
            ans[i]=MAX;
        }
        else{
            ans[i]=ans[mn[i]]+1;
        }
    }
    while(q--){
        int n;
        cin>>n;
        if(ans[n]>=MAX){
            cout<<"oo\n";
        }
        else{
            cout<<ans[n]<<"\n";
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 183 ms 156888 KB Output is correct
2 Correct 226 ms 156844 KB Output is correct
3 Correct 194 ms 156800 KB Output is correct
4 Correct 183 ms 156928 KB Output is correct
5 Correct 205 ms 156932 KB Output is correct
6 Correct 188 ms 156756 KB Output is correct
7 Correct 219 ms 156804 KB Output is correct
8 Correct 207 ms 156928 KB Output is correct
9 Correct 238 ms 156840 KB Output is correct
10 Correct 279 ms 156812 KB Output is correct
11 Correct 298 ms 156808 KB Output is correct
12 Correct 201 ms 156848 KB Output is correct
13 Correct 423 ms 156812 KB Output is correct
14 Correct 413 ms 156928 KB Output is correct
15 Correct 238 ms 157000 KB Output is correct
16 Correct 222 ms 156880 KB Output is correct
17 Correct 212 ms 156912 KB Output is correct
18 Correct 183 ms 156916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 205 ms 157068 KB Output is correct
2 Correct 224 ms 157284 KB Output is correct
3 Correct 500 ms 157232 KB Output is correct
4 Correct 256 ms 156828 KB Output is correct
5 Correct 378 ms 157132 KB Output is correct
6 Correct 203 ms 156884 KB Output is correct
7 Correct 199 ms 156932 KB Output is correct
8 Correct 249 ms 156880 KB Output is correct
9 Correct 410 ms 157336 KB Output is correct
10 Correct 509 ms 157212 KB Output is correct
11 Correct 511 ms 157076 KB Output is correct
12 Correct 306 ms 156816 KB Output is correct
13 Correct 190 ms 156828 KB Output is correct
14 Correct 248 ms 156876 KB Output is correct
15 Correct 432 ms 157192 KB Output is correct
16 Correct 223 ms 157284 KB Output is correct
17 Correct 458 ms 156828 KB Output is correct
18 Correct 416 ms 157320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 421 ms 157248 KB Output is correct
2 Correct 532 ms 157236 KB Output is correct
3 Correct 521 ms 157320 KB Output is correct
4 Correct 325 ms 157176 KB Output is correct
5 Correct 242 ms 157540 KB Output is correct
6 Correct 419 ms 157260 KB Output is correct
7 Correct 401 ms 157440 KB Output is correct
8 Correct 423 ms 157260 KB Output is correct
9 Correct 453 ms 157348 KB Output is correct
10 Correct 354 ms 156932 KB Output is correct
11 Correct 306 ms 157052 KB Output is correct
12 Correct 397 ms 156992 KB Output is correct
13 Correct 541 ms 157428 KB Output is correct
14 Correct 322 ms 157500 KB Output is correct
15 Correct 399 ms 157004 KB Output is correct
16 Correct 465 ms 157064 KB Output is correct
17 Correct 441 ms 157100 KB Output is correct
18 Correct 510 ms 157144 KB Output is correct
19 Correct 225 ms 157064 KB Output is correct
20 Correct 543 ms 157336 KB Output is correct
21 Correct 341 ms 157488 KB Output is correct
22 Correct 528 ms 157572 KB Output is correct
23 Correct 276 ms 157240 KB Output is correct
24 Correct 232 ms 157228 KB Output is correct
25 Correct 368 ms 157260 KB Output is correct
26 Correct 317 ms 157292 KB Output is correct
27 Correct 550 ms 157440 KB Output is correct
28 Correct 217 ms 157176 KB Output is correct
29 Correct 507 ms 157548 KB Output is correct
30 Correct 486 ms 157456 KB Output is correct
31 Correct 242 ms 157184 KB Output is correct
32 Correct 281 ms 157248 KB Output is correct
33 Correct 205 ms 157228 KB Output is correct
34 Correct 397 ms 157440 KB Output is correct
35 Correct 244 ms 157300 KB Output is correct
36 Correct 524 ms 157532 KB Output is correct
37 Correct 281 ms 157572 KB Output is correct
38 Correct 431 ms 157276 KB Output is correct
39 Correct 245 ms 157172 KB Output is correct
40 Correct 377 ms 157260 KB Output is correct
41 Correct 337 ms 157384 KB Output is correct
42 Correct 468 ms 157232 KB Output is correct