Submission #283091

# Submission time Handle Problem Language Result Execution time Memory
283091 2020-08-25T09:55:12 Z egekabas Brunhilda’s Birthday (BOI13_brunhilda) C++14
7.77778 / 100
1000 ms 41080 KB
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;
int n, q;
int p[100009];
int ans[10000001];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    
    cin >> n >> q;
    for(int i = 0; i < n; ++i)
        cin >> p[i];
    reverse(p, p+n);
    ans[0] = 0;
    int lim = 1e7+1;
    for(int i = 1; i < lim; ++i){
        int goback = -1;
        for(int j = 0; j < n; ++j){
            if(i%p[j] <= goback)
                break;
            goback = i%p[j];
        }
        if(goback == 0){
            lim = i;
            break;
        }
        ans[i] = 1+ans[i-goback];
    }
    while(q--){
        int x;
        cin >> x;
        if(x >= lim)
            cout << "oo\n";
        else
            cout << ans[x] << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Incorrect 6 ms 1280 KB Output isn't correct
3 Incorrect 1 ms 384 KB Output isn't correct
4 Incorrect 197 ms 39652 KB Output isn't correct
5 Correct 1 ms 384 KB Output is correct
6 Incorrect 1 ms 384 KB Output isn't correct
7 Incorrect 0 ms 384 KB Output isn't correct
8 Incorrect 0 ms 384 KB Output isn't correct
9 Correct 1 ms 384 KB Output is correct
10 Incorrect 1 ms 384 KB Output isn't correct
11 Incorrect 1 ms 384 KB Output isn't correct
12 Correct 189 ms 35192 KB Output is correct
13 Correct 308 ms 39544 KB Output is correct
14 Correct 312 ms 39544 KB Output is correct
15 Incorrect 5 ms 1152 KB Output isn't correct
16 Incorrect 6 ms 1280 KB Output isn't correct
17 Incorrect 8 ms 1792 KB Output isn't correct
18 Incorrect 197 ms 39636 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1083 ms 4344 KB Time limit exceeded
2 Execution timed out 1090 ms 36728 KB Time limit exceeded
3 Execution timed out 1098 ms 10872 KB Time limit exceeded
4 Execution timed out 1093 ms 2424 KB Time limit exceeded
5 Execution timed out 1080 ms 6408 KB Time limit exceeded
6 Correct 932 ms 39544 KB Output is correct
7 Execution timed out 1094 ms 4344 KB Time limit exceeded
8 Incorrect 598 ms 39544 KB Output isn't correct
9 Execution timed out 1064 ms 6776 KB Time limit exceeded
10 Execution timed out 1034 ms 11108 KB Time limit exceeded
11 Execution timed out 1091 ms 8212 KB Time limit exceeded
12 Execution timed out 1095 ms 11652 KB Time limit exceeded
13 Execution timed out 1046 ms 3068 KB Time limit exceeded
14 Execution timed out 1091 ms 2480 KB Time limit exceeded
15 Execution timed out 1097 ms 3996 KB Time limit exceeded
16 Execution timed out 1094 ms 36728 KB Time limit exceeded
17 Correct 335 ms 39544 KB Output is correct
18 Execution timed out 1089 ms 21112 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 5256 KB Time limit exceeded
2 Execution timed out 1087 ms 3960 KB Time limit exceeded
3 Execution timed out 1091 ms 5160 KB Time limit exceeded
4 Execution timed out 1076 ms 2296 KB Time limit exceeded
5 Execution timed out 1096 ms 19064 KB Time limit exceeded
6 Execution timed out 1094 ms 1528 KB Time limit exceeded
7 Execution timed out 1029 ms 13048 KB Time limit exceeded
8 Execution timed out 1087 ms 5240 KB Time limit exceeded
9 Execution timed out 1082 ms 5368 KB Time limit exceeded
10 Execution timed out 1093 ms 1704 KB Time limit exceeded
11 Execution timed out 1093 ms 1784 KB Time limit exceeded
12 Execution timed out 1090 ms 1600 KB Time limit exceeded
13 Incorrect 856 ms 41080 KB Output isn't correct
14 Incorrect 14 ms 1536 KB Output isn't correct
15 Execution timed out 1076 ms 1620 KB Time limit exceeded
16 Execution timed out 1092 ms 1356 KB Time limit exceeded
17 Execution timed out 1092 ms 4216 KB Time limit exceeded
18 Execution timed out 1078 ms 4224 KB Time limit exceeded
19 Execution timed out 1087 ms 3948 KB Time limit exceeded
20 Execution timed out 1086 ms 5264 KB Time limit exceeded
21 Incorrect 33 ms 5624 KB Output isn't correct
22 Execution timed out 1085 ms 7672 KB Time limit exceeded
23 Execution timed out 1094 ms 4992 KB Time limit exceeded
24 Execution timed out 1073 ms 36048 KB Time limit exceeded
25 Execution timed out 1079 ms 5756 KB Time limit exceeded
26 Execution timed out 1093 ms 2356 KB Time limit exceeded
27 Execution timed out 1086 ms 8080 KB Time limit exceeded
28 Incorrect 292 ms 40824 KB Output isn't correct
29 Execution timed out 1088 ms 7668 KB Time limit exceeded
30 Execution timed out 1074 ms 5356 KB Time limit exceeded
31 Execution timed out 1093 ms 2124 KB Time limit exceeded
32 Execution timed out 1072 ms 3020 KB Time limit exceeded
33 Execution timed out 1076 ms 5964 KB Time limit exceeded
34 Execution timed out 1079 ms 12928 KB Time limit exceeded
35 Incorrect 524 ms 40672 KB Output isn't correct
36 Execution timed out 1090 ms 7508 KB Time limit exceeded
37 Execution timed out 1086 ms 19192 KB Time limit exceeded
38 Execution timed out 1092 ms 1656 KB Time limit exceeded
39 Execution timed out 1082 ms 3552 KB Time limit exceeded
40 Execution timed out 1093 ms 1656 KB Time limit exceeded
41 Execution timed out 1092 ms 30572 KB Time limit exceeded
42 Incorrect 373 ms 40824 KB Output isn't correct