답안 #493710

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
493710 2021-12-12T16:32:53 Z _Monkey_ Brunhilda’s Birthday (BOI13_brunhilda) C++17
1.11111 / 100
1000 ms 81096 KB
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define el '\n'
#define ld long double
const int maxn=1e5+1,nn=1e7+1;
int a[maxn],n,m,q,p,oo,ans,k,f[nn],ut[nn];
int t;
bool ok;
void check(){
    t=1;
    ok=0;
    for(int i=0;i<m;++i){
        k=t*a[i];
        if(t*a[i]<t || t*a[i]>oo || k/a[i]!=t){
            ok=1;
            return;
        }
        t=t*a[i];
    }
}
int sol(int z){
    if(f[z]>=0) return f[z];
    return f[z]=sol(z-ut[z])+1;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin >> m >> q;
    for(int i=0;i<m;++i) cin >> a[i];
    sort(a+0,a+m);
    memset(f,-1,sizeof f);
    f[0]=0;
    for(int i=0;i<m;++i){
        for(int j=1;j*a[i]<nn;j++){
            ut[j*a[i]-1]=a[i]-1;
        }
    }
    int ma;
    for(int i=1;i<a[m-1];++i) ut[i]=i;
    for(int z=a[m-1];z<nn;++z)
        if(ut[z]==0){
            ma=0;
            for(int i=m-1;i>=0;--i){
                if(ma>=a[i]) break;
                if(z%a[i]>ma) ma=z%a[i];
            }
            ut[z]=ma;
        }
    oo=1e7;
    check();
    while(q--){
        cin >> n;
        if(ok){
            cout << sol(n);
        } else {
            if(n>=t){
                cout << "oo";
            } else {
                cout << sol(n);
            }
        }
        cout << el;
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 191 ms 78584 KB Output isn't correct
2 Incorrect 221 ms 78576 KB Output isn't correct
3 Incorrect 97 ms 78596 KB Output isn't correct
4 Incorrect 501 ms 78572 KB Output isn't correct
5 Incorrect 278 ms 78584 KB Output isn't correct
6 Incorrect 188 ms 78540 KB Output isn't correct
7 Incorrect 98 ms 78568 KB Output isn't correct
8 Incorrect 89 ms 78500 KB Output isn't correct
9 Incorrect 111 ms 78556 KB Output isn't correct
10 Incorrect 119 ms 78540 KB Output isn't correct
11 Incorrect 156 ms 78584 KB Output isn't correct
12 Execution timed out 1042 ms 78572 KB Time limit exceeded
13 Incorrect 308 ms 78580 KB Output isn't correct
14 Correct 317 ms 78580 KB Output is correct
15 Incorrect 191 ms 78572 KB Output isn't correct
16 Incorrect 223 ms 78572 KB Output isn't correct
17 Incorrect 368 ms 78496 KB Output isn't correct
18 Incorrect 520 ms 78576 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1097 ms 78532 KB Time limit exceeded
2 Execution timed out 1095 ms 78848 KB Time limit exceeded
3 Execution timed out 1089 ms 78796 KB Time limit exceeded
4 Execution timed out 1104 ms 78524 KB Time limit exceeded
5 Execution timed out 1099 ms 78660 KB Time limit exceeded
6 Execution timed out 1068 ms 78540 KB Time limit exceeded
7 Execution timed out 1104 ms 78532 KB Time limit exceeded
8 Execution timed out 1089 ms 78552 KB Time limit exceeded
9 Execution timed out 1097 ms 78784 KB Time limit exceeded
10 Execution timed out 1095 ms 78788 KB Time limit exceeded
11 Execution timed out 1095 ms 78712 KB Time limit exceeded
12 Incorrect 942 ms 78540 KB Output isn't correct
13 Execution timed out 1098 ms 78476 KB Time limit exceeded
14 Execution timed out 1102 ms 78560 KB Time limit exceeded
15 Execution timed out 1094 ms 78788 KB Time limit exceeded
16 Execution timed out 1084 ms 78868 KB Time limit exceeded
17 Incorrect 309 ms 78600 KB Output isn't correct
18 Execution timed out 1103 ms 78860 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1092 ms 78764 KB Time limit exceeded
2 Execution timed out 1097 ms 78704 KB Time limit exceeded
3 Execution timed out 1104 ms 78668 KB Time limit exceeded
4 Execution timed out 1080 ms 78544 KB Time limit exceeded
5 Execution timed out 1103 ms 78916 KB Time limit exceeded
6 Execution timed out 1091 ms 78532 KB Time limit exceeded
7 Execution timed out 1098 ms 78916 KB Time limit exceeded
8 Execution timed out 1067 ms 78668 KB Time limit exceeded
9 Execution timed out 1098 ms 78692 KB Time limit exceeded
10 Execution timed out 1091 ms 78540 KB Time limit exceeded
11 Execution timed out 1099 ms 78540 KB Time limit exceeded
12 Execution timed out 1100 ms 78600 KB Time limit exceeded
13 Execution timed out 1096 ms 78612 KB Time limit exceeded
14 Incorrect 183 ms 81096 KB Output isn't correct
15 Incorrect 751 ms 78704 KB Output isn't correct
16 Incorrect 834 ms 78736 KB Output isn't correct
17 Execution timed out 1092 ms 78732 KB Time limit exceeded
18 Execution timed out 1102 ms 78660 KB Time limit exceeded
19 Execution timed out 1070 ms 78668 KB Time limit exceeded
20 Execution timed out 1104 ms 78668 KB Time limit exceeded
21 Incorrect 157 ms 79780 KB Output isn't correct
22 Execution timed out 1102 ms 78940 KB Time limit exceeded
23 Execution timed out 1091 ms 78668 KB Time limit exceeded
24 Execution timed out 1087 ms 78520 KB Time limit exceeded
25 Execution timed out 1103 ms 78528 KB Time limit exceeded
26 Execution timed out 1099 ms 78540 KB Time limit exceeded
27 Execution timed out 1096 ms 78844 KB Time limit exceeded
28 Incorrect 931 ms 78964 KB Output isn't correct
29 Execution timed out 1085 ms 78920 KB Time limit exceeded
30 Execution timed out 1088 ms 78796 KB Time limit exceeded
31 Execution timed out 1087 ms 78576 KB Time limit exceeded
32 Execution timed out 1100 ms 78532 KB Time limit exceeded
33 Execution timed out 1091 ms 78540 KB Time limit exceeded
34 Execution timed out 1096 ms 78944 KB Time limit exceeded
35 Execution timed out 1086 ms 78504 KB Time limit exceeded
36 Execution timed out 1093 ms 78808 KB Time limit exceeded
37 Execution timed out 1099 ms 78916 KB Time limit exceeded
38 Execution timed out 1083 ms 78572 KB Time limit exceeded
39 Execution timed out 1091 ms 78660 KB Time limit exceeded
40 Execution timed out 1093 ms 78540 KB Time limit exceeded
41 Execution timed out 1090 ms 78916 KB Time limit exceeded
42 Incorrect 352 ms 79100 KB Output isn't correct