답안 #331146

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
331146 2020-11-27T14:12:29 Z Sho10 Brunhilda’s Birthday (BOI13_brunhilda) C++14
100 / 100
646 ms 157548 KB
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int n,m,ans[20000005],a[20000005];
int32_t main(){
CODE_START
n=2e7;
cin>>m;
ll q;
cin>>q;
for(ll i=1;i<=m;i++)
{
    int x;
    cin>>x;
    for(ll j=x;j<=n;j+=x){
        a[j-1]=max(a[j-1],x-1);
    }
}
for(ll i=n;i>=1;i--)
{
    a[i]=max(a[i],a[i+1]-1);
}
for(ll i=1;i<=n;i++)
{
    if(a[i]&&(ans[i-a[i]]||i-a[i]==0)){
        ans[i]=ans[i-a[i]]+1;
    }
}
while(q--){
    ll x;
    cin>>x;
    if(ans[x]){
        cout<<ans[x]<<endl;
    }else cout<<"oo"<<endl;
}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 163 ms 78956 KB Output is correct
2 Correct 220 ms 156908 KB Output is correct
3 Correct 169 ms 79852 KB Output is correct
4 Correct 169 ms 156908 KB Output is correct
5 Correct 191 ms 156908 KB Output is correct
6 Correct 153 ms 78828 KB Output is correct
7 Correct 183 ms 79852 KB Output is correct
8 Correct 183 ms 82284 KB Output is correct
9 Correct 231 ms 156908 KB Output is correct
10 Correct 287 ms 156908 KB Output is correct
11 Correct 253 ms 156908 KB Output is correct
12 Correct 175 ms 156904 KB Output is correct
13 Correct 494 ms 156908 KB Output is correct
14 Correct 477 ms 156908 KB Output is correct
15 Correct 233 ms 156908 KB Output is correct
16 Correct 219 ms 156908 KB Output is correct
17 Correct 217 ms 156908 KB Output is correct
18 Correct 170 ms 156908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 202 ms 157164 KB Output is correct
2 Correct 229 ms 157036 KB Output is correct
3 Correct 585 ms 157036 KB Output is correct
4 Correct 258 ms 156908 KB Output is correct
5 Correct 408 ms 157020 KB Output is correct
6 Correct 215 ms 156908 KB Output is correct
7 Correct 202 ms 156908 KB Output is correct
8 Correct 254 ms 156908 KB Output is correct
9 Correct 484 ms 157036 KB Output is correct
10 Correct 586 ms 157164 KB Output is correct
11 Correct 573 ms 157036 KB Output is correct
12 Correct 315 ms 156996 KB Output is correct
13 Correct 189 ms 156964 KB Output is correct
14 Correct 247 ms 157036 KB Output is correct
15 Correct 476 ms 157036 KB Output is correct
16 Correct 238 ms 157036 KB Output is correct
17 Correct 495 ms 157036 KB Output is correct
18 Correct 467 ms 157036 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 486 ms 157164 KB Output is correct
2 Correct 609 ms 157036 KB Output is correct
3 Correct 604 ms 157164 KB Output is correct
4 Correct 357 ms 157420 KB Output is correct
5 Correct 268 ms 157292 KB Output is correct
6 Correct 482 ms 157164 KB Output is correct
7 Correct 429 ms 157036 KB Output is correct
8 Correct 491 ms 157036 KB Output is correct
9 Correct 479 ms 157036 KB Output is correct
10 Correct 382 ms 156908 KB Output is correct
11 Correct 330 ms 156908 KB Output is correct
12 Correct 440 ms 156908 KB Output is correct
13 Correct 569 ms 157200 KB Output is correct
14 Correct 318 ms 157548 KB Output is correct
15 Correct 467 ms 157036 KB Output is correct
16 Correct 530 ms 157036 KB Output is correct
17 Correct 470 ms 156908 KB Output is correct
18 Correct 601 ms 156908 KB Output is correct
19 Correct 202 ms 156908 KB Output is correct
20 Correct 600 ms 157164 KB Output is correct
21 Correct 377 ms 157548 KB Output is correct
22 Correct 607 ms 157244 KB Output is correct
23 Correct 278 ms 157148 KB Output is correct
24 Correct 226 ms 157164 KB Output is correct
25 Correct 403 ms 157292 KB Output is correct
26 Correct 361 ms 157164 KB Output is correct
27 Correct 646 ms 157012 KB Output is correct
28 Correct 229 ms 157164 KB Output is correct
29 Correct 566 ms 157164 KB Output is correct
30 Correct 524 ms 157164 KB Output is correct
31 Correct 258 ms 157164 KB Output is correct
32 Correct 292 ms 157292 KB Output is correct
33 Correct 196 ms 157164 KB Output is correct
34 Correct 432 ms 157036 KB Output is correct
35 Correct 239 ms 157164 KB Output is correct
36 Correct 591 ms 157164 KB Output is correct
37 Correct 268 ms 157164 KB Output is correct
38 Correct 497 ms 157164 KB Output is correct
39 Correct 245 ms 157164 KB Output is correct
40 Correct 415 ms 157164 KB Output is correct
41 Correct 374 ms 157280 KB Output is correct
42 Correct 547 ms 157292 KB Output is correct