Submission #493705

# Submission time Handle Problem Language Result Execution time Memory
493705 2021-12-12T16:11:06 Z _Monkey_ Brunhilda’s Birthday (BOI13_brunhilda) C++17
28.0952 / 100
1000 ms 1100 KB
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define el '\n'
#define ld long double
const int maxn=1e5+1;

ll a[maxn],n,m,q,p,oo,ans,k;
ll 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];
    }
}
void sol(){
    ans=0;
    while(n%a[m-1]!=0){
        ans++;
        int ma=0;
        for(int i=0;i<m;++i) if(n%a[i]>ma) ma=n%a[i];
        n-=ma;
    }
    ans+=(n/a[m-1])*2;
    cout << ans;
}
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);
    oo=1e8;
    check();
    while(q--){
        cin >> n;
        if(ok){
            sol();
        } else {
            if(n>=t){
                cout << "oo";
            } else {
                sol();
            }
        }
        cout << el;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 7 ms 332 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Incorrect 1 ms 332 KB Output isn't correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 7 ms 204 KB Output is correct
14 Correct 49 ms 332 KB Output is correct
15 Incorrect 1 ms 204 KB Output isn't correct
16 Incorrect 1 ms 204 KB Output isn't correct
17 Incorrect 9 ms 344 KB Output isn't correct
18 Correct 7 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 332 KB Output is correct
2 Correct 9 ms 1036 KB Output is correct
3 Correct 7 ms 844 KB Output is correct
4 Incorrect 1 ms 332 KB Output isn't correct
5 Correct 5 ms 716 KB Output is correct
6 Incorrect 1 ms 332 KB Output isn't correct
7 Correct 2 ms 332 KB Output is correct
8 Incorrect 1 ms 332 KB Output isn't correct
9 Correct 11 ms 820 KB Output is correct
10 Correct 7 ms 844 KB Output is correct
11 Incorrect 4 ms 588 KB Output isn't correct
12 Incorrect 1 ms 332 KB Output isn't correct
13 Correct 1 ms 332 KB Output is correct
14 Incorrect 1 ms 332 KB Output isn't correct
15 Correct 5 ms 588 KB Output is correct
16 Correct 10 ms 972 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 12 ms 1100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 588 KB Time limit exceeded
2 Execution timed out 1085 ms 716 KB Time limit exceeded
3 Execution timed out 1056 ms 696 KB Time limit exceeded
4 Execution timed out 1087 ms 332 KB Time limit exceeded
5 Execution timed out 1098 ms 972 KB Time limit exceeded
6 Execution timed out 1080 ms 364 KB Time limit exceeded
7 Execution timed out 1095 ms 972 KB Time limit exceeded
8 Execution timed out 1081 ms 588 KB Time limit exceeded
9 Execution timed out 1078 ms 588 KB Time limit exceeded
10 Execution timed out 1085 ms 344 KB Time limit exceeded
11 Execution timed out 1089 ms 332 KB Time limit exceeded
12 Execution timed out 1091 ms 352 KB Time limit exceeded
13 Execution timed out 1091 ms 544 KB Time limit exceeded
14 Incorrect 70 ms 808 KB Output isn't correct
15 Execution timed out 1088 ms 344 KB Time limit exceeded
16 Execution timed out 1088 ms 360 KB Time limit exceeded
17 Execution timed out 1090 ms 588 KB Time limit exceeded
18 Execution timed out 1074 ms 716 KB Time limit exceeded
19 Execution timed out 1089 ms 348 KB Time limit exceeded
20 Execution timed out 1087 ms 692 KB Time limit exceeded
21 Correct 130 ms 808 KB Output is correct
22 Execution timed out 1089 ms 972 KB Time limit exceeded
23 Execution timed out 1086 ms 460 KB Time limit exceeded
24 Execution timed out 1084 ms 464 KB Time limit exceeded
25 Execution timed out 1078 ms 460 KB Time limit exceeded
26 Execution timed out 1089 ms 332 KB Time limit exceeded
27 Execution timed out 1097 ms 972 KB Time limit exceeded
28 Incorrect 833 ms 704 KB Output isn't correct
29 Execution timed out 1092 ms 972 KB Time limit exceeded
30 Execution timed out 1091 ms 844 KB Time limit exceeded
31 Execution timed out 1093 ms 332 KB Time limit exceeded
32 Execution timed out 1090 ms 456 KB Time limit exceeded
33 Execution timed out 1093 ms 444 KB Time limit exceeded
34 Execution timed out 1091 ms 972 KB Time limit exceeded
35 Execution timed out 1096 ms 588 KB Time limit exceeded
36 Execution timed out 1087 ms 972 KB Time limit exceeded
37 Execution timed out 1086 ms 1072 KB Time limit exceeded
38 Execution timed out 1085 ms 376 KB Time limit exceeded
39 Execution timed out 1094 ms 332 KB Time limit exceeded
40 Execution timed out 1091 ms 380 KB Time limit exceeded
41 Execution timed out 1096 ms 972 KB Time limit exceeded
42 Execution timed out 1094 ms 468 KB Time limit exceeded