답안 #714465

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
714465 2023-03-24T14:42:24 Z Ahmed57 Brunhilda’s Birthday (BOI13_brunhilda) C++14
100 / 100
738 ms 124196 KB
#include <bits/stdc++.h>
using namespace std;
int sub[20000001];
int dp[10000001];
int main(){
    int n,q;
    cin>>n>>q;
    map<int,int>mp;
    for(int i= 0;i<n;i++){
        int x;cin>>x;
        mp[x]++;
    }
    for(auto i:mp){
        for(int j= i.first-1;j<=2e7;j+=i.first){
            sub[j] = max(i.first-1,sub[j]);
        }
    }
    for(int i = int(2e7)-1;i>=1;i--)sub[i]=max(sub[i],sub[i+1]-1);
    dp[0]= 0;
    for(int i = 1;i<=1e7;i++){
        dp[i]=(sub[i]==0?1e9:dp[i-sub[i]]+1);
    }
    while(q--){
        int a;
        cin>>a;if(dp[a]>=1e9)cout<<"oo\n";
        else cout<<dp[a]<<"\n";
    }
    return 0;
}
/*
20 10
13 37 13 37 13 37 13 37 13 37 13 37 13 37 13 37 13 37 13 37
13 37 13 37 13 37 13 37 13 37
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 162 ms 117612 KB Output is correct
2 Correct 208 ms 117580 KB Output is correct
3 Correct 170 ms 117704 KB Output is correct
4 Correct 174 ms 117660 KB Output is correct
5 Correct 197 ms 117588 KB Output is correct
6 Correct 154 ms 117612 KB Output is correct
7 Correct 174 ms 117768 KB Output is correct
8 Correct 189 ms 117612 KB Output is correct
9 Correct 213 ms 117608 KB Output is correct
10 Correct 231 ms 117700 KB Output is correct
11 Correct 233 ms 117708 KB Output is correct
12 Correct 147 ms 117612 KB Output is correct
13 Correct 376 ms 117648 KB Output is correct
14 Correct 433 ms 117704 KB Output is correct
15 Correct 205 ms 117608 KB Output is correct
16 Correct 203 ms 117640 KB Output is correct
17 Correct 224 ms 117652 KB Output is correct
18 Correct 172 ms 117716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 199 ms 118252 KB Output is correct
2 Correct 239 ms 122596 KB Output is correct
3 Correct 493 ms 121364 KB Output is correct
4 Correct 227 ms 117856 KB Output is correct
5 Correct 360 ms 120368 KB Output is correct
6 Correct 203 ms 117672 KB Output is correct
7 Correct 196 ms 118260 KB Output is correct
8 Correct 215 ms 117660 KB Output is correct
9 Correct 427 ms 121452 KB Output is correct
10 Correct 515 ms 121420 KB Output is correct
11 Correct 473 ms 119820 KB Output is correct
12 Correct 272 ms 117836 KB Output is correct
13 Correct 170 ms 117764 KB Output is correct
14 Correct 219 ms 117792 KB Output is correct
15 Correct 406 ms 119852 KB Output is correct
16 Correct 232 ms 122596 KB Output is correct
17 Correct 419 ms 117768 KB Output is correct
18 Correct 424 ms 123160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 475 ms 120764 KB Output is correct
2 Correct 597 ms 120740 KB Output is correct
3 Correct 608 ms 121048 KB Output is correct
4 Correct 433 ms 118860 KB Output is correct
5 Correct 547 ms 124004 KB Output is correct
6 Correct 738 ms 119148 KB Output is correct
7 Correct 585 ms 123628 KB Output is correct
8 Correct 469 ms 120704 KB Output is correct
9 Correct 469 ms 120676 KB Output is correct
10 Correct 345 ms 118124 KB Output is correct
11 Correct 303 ms 118052 KB Output is correct
12 Correct 389 ms 118220 KB Output is correct
13 Correct 591 ms 120284 KB Output is correct
14 Correct 420 ms 119056 KB Output is correct
15 Correct 435 ms 118228 KB Output is correct
16 Correct 470 ms 118180 KB Output is correct
17 Correct 405 ms 120216 KB Output is correct
18 Correct 524 ms 120652 KB Output is correct
19 Correct 207 ms 118092 KB Output is correct
20 Correct 567 ms 120940 KB Output is correct
21 Correct 468 ms 119068 KB Output is correct
22 Correct 675 ms 124196 KB Output is correct
23 Correct 391 ms 120396 KB Output is correct
24 Correct 333 ms 118744 KB Output is correct
25 Correct 463 ms 118896 KB Output is correct
26 Correct 418 ms 118860 KB Output is correct
27 Correct 628 ms 123612 KB Output is correct
28 Correct 331 ms 118728 KB Output is correct
29 Correct 632 ms 124012 KB Output is correct
30 Correct 623 ms 122452 KB Output is correct
31 Correct 372 ms 118780 KB Output is correct
32 Correct 371 ms 118952 KB Output is correct
33 Correct 304 ms 118688 KB Output is correct
34 Correct 469 ms 123724 KB Output is correct
35 Correct 366 ms 118876 KB Output is correct
36 Correct 651 ms 123564 KB Output is correct
37 Correct 413 ms 124060 KB Output is correct
38 Correct 540 ms 119076 KB Output is correct
39 Correct 340 ms 118800 KB Output is correct
40 Correct 460 ms 119100 KB Output is correct
41 Correct 439 ms 123564 KB Output is correct
42 Correct 590 ms 118964 KB Output is correct