Submission #493709

# Submission time Handle Problem Language Result Execution time Memory
493709 2021-12-12T16:31:18 Z _Monkey_ Brunhilda’s Birthday (BOI13_brunhilda) C++17
1.11111 / 100
1000 ms 78964 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 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;
}
# Verdict Execution time Memory Grader output
1 Incorrect 196 ms 78540 KB Output isn't correct
2 Incorrect 225 ms 78452 KB Output isn't correct
3 Incorrect 104 ms 78532 KB Output isn't correct
4 Incorrect 531 ms 78576 KB Output isn't correct
5 Incorrect 295 ms 78568 KB Output isn't correct
6 Incorrect 198 ms 78576 KB Output isn't correct
7 Incorrect 105 ms 78540 KB Output isn't correct
8 Incorrect 92 ms 78576 KB Output isn't correct
9 Incorrect 111 ms 78560 KB Output isn't correct
10 Incorrect 116 ms 78492 KB Output isn't correct
11 Incorrect 155 ms 78692 KB Output isn't correct
12 Execution timed out 1086 ms 78532 KB Time limit exceeded
13 Incorrect 310 ms 78708 KB Output isn't correct
14 Correct 325 ms 78584 KB Output is correct
15 Incorrect 198 ms 78660 KB Output isn't correct
16 Incorrect 221 ms 78572 KB Output isn't correct
17 Incorrect 376 ms 78572 KB Output isn't correct
18 Incorrect 519 ms 78532 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 78548 KB Time limit exceeded
2 Execution timed out 1088 ms 78916 KB Time limit exceeded
3 Execution timed out 1098 ms 78836 KB Time limit exceeded
4 Execution timed out 1094 ms 78512 KB Time limit exceeded
5 Execution timed out 1066 ms 78660 KB Time limit exceeded
6 Execution timed out 1085 ms 78584 KB Time limit exceeded
7 Execution timed out 1093 ms 78540 KB Time limit exceeded
8 Execution timed out 1084 ms 78540 KB Time limit exceeded
9 Execution timed out 1096 ms 78792 KB Time limit exceeded
10 Execution timed out 1096 ms 78796 KB Time limit exceeded
11 Execution timed out 1091 ms 78680 KB Time limit exceeded
12 Incorrect 975 ms 78584 KB Output isn't correct
13 Execution timed out 1092 ms 78504 KB Time limit exceeded
14 Execution timed out 1093 ms 78552 KB Time limit exceeded
15 Execution timed out 1098 ms 78660 KB Time limit exceeded
16 Execution timed out 1069 ms 78916 KB Time limit exceeded
17 Incorrect 294 ms 78584 KB Output isn't correct
18 Execution timed out 1087 ms 78912 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 78756 KB Time limit exceeded
2 Execution timed out 1091 ms 78688 KB Time limit exceeded
3 Execution timed out 1099 ms 78736 KB Time limit exceeded
4 Execution timed out 1093 ms 78564 KB Time limit exceeded
5 Execution timed out 1097 ms 78916 KB Time limit exceeded
6 Execution timed out 1101 ms 78540 KB Time limit exceeded
7 Execution timed out 1099 ms 78912 KB Time limit exceeded
8 Execution timed out 1091 ms 78660 KB Time limit exceeded
9 Execution timed out 1089 ms 78668 KB Time limit exceeded
10 Execution timed out 1090 ms 78536 KB Time limit exceeded
11 Execution timed out 1098 ms 78532 KB Time limit exceeded
12 Execution timed out 1087 ms 78600 KB Time limit exceeded
13 Execution timed out 1094 ms 78700 KB Time limit exceeded
14 Execution timed out 1080 ms 78580 KB Time limit exceeded
15 Incorrect 954 ms 78688 KB Output isn't correct
16 Execution timed out 1014 ms 78600 KB Time limit exceeded
17 Execution timed out 1089 ms 78664 KB Time limit exceeded
18 Execution timed out 1083 ms 78668 KB Time limit exceeded
19 Execution timed out 1094 ms 78540 KB Time limit exceeded
20 Execution timed out 1089 ms 78660 KB Time limit exceeded
21 Execution timed out 1101 ms 78572 KB Time limit exceeded
22 Execution timed out 1098 ms 78920 KB Time limit exceeded
23 Execution timed out 1095 ms 78640 KB Time limit exceeded
24 Execution timed out 1096 ms 78512 KB Time limit exceeded
25 Execution timed out 1052 ms 78540 KB Time limit exceeded
26 Execution timed out 1070 ms 78532 KB Time limit exceeded
27 Execution timed out 1088 ms 78916 KB Time limit exceeded
28 Incorrect 974 ms 78964 KB Output isn't correct
29 Execution timed out 1100 ms 78888 KB Time limit exceeded
30 Execution timed out 1083 ms 78840 KB Time limit exceeded
31 Execution timed out 1094 ms 78536 KB Time limit exceeded
32 Execution timed out 1085 ms 78468 KB Time limit exceeded
33 Execution timed out 1093 ms 78532 KB Time limit exceeded
34 Execution timed out 1093 ms 78916 KB Time limit exceeded
35 Execution timed out 1091 ms 78540 KB Time limit exceeded
36 Execution timed out 1083 ms 78916 KB Time limit exceeded
37 Execution timed out 1089 ms 78916 KB Time limit exceeded
38 Execution timed out 1094 ms 78528 KB Time limit exceeded
39 Execution timed out 1098 ms 78532 KB Time limit exceeded
40 Execution timed out 1096 ms 78532 KB Time limit exceeded
41 Execution timed out 1100 ms 78916 KB Time limit exceeded
42 Execution timed out 1091 ms 78860 KB Time limit exceeded