Submission #388563

# Submission time Handle Problem Language Result Execution time Memory
388563 2021-04-12T06:40:45 Z Aryan_Raina Brunhilda’s Birthday (BOI13_brunhilda) C++14
97.7778 / 100
345 ms 158580 KB
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define ld long double
#define ar array
 
const int INF = 1e17;
const int MOD = 1e9 + 7;

const int MXN = 1e7+9;
int largestPrime[MXN], dp[MXN];
int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int m, q; cin>>m>>q;
    for (int i = 0; i < m; i++) {
        int p; cin>>p;
        for (int j = 0; j < MXN; j += p) 
            largestPrime[j] = p;
    }
    int ind = 0; // represents the first index which is last multiple of some prime
    for (int i = 1; i < MXN; i++) {
        while (ind + largestPrime[ind] <= i || dp[ind] > INF/2) 
            ind++;
        if (ind == i) dp[i] = INF;
        else dp[i] = dp[ind] + 1;
    }   
    while (q--) {
        int x; cin>>x;
        if (dp[x] > INF/2) cout<<"oo\n";
        else cout<<dp[x]<<"\n";
    }
} 
# Verdict Execution time Memory Grader output
1 Incorrect 121 ms 156764 KB Output isn't correct
2 Correct 113 ms 156796 KB Output is correct
3 Correct 130 ms 156788 KB Output is correct
4 Correct 90 ms 156868 KB Output is correct
5 Correct 107 ms 156788 KB Output is correct
6 Incorrect 123 ms 156840 KB Output isn't correct
7 Correct 131 ms 156736 KB Output is correct
8 Correct 149 ms 156748 KB Output is correct
9 Correct 137 ms 156740 KB Output is correct
10 Correct 154 ms 156932 KB Output is correct
11 Correct 139 ms 156812 KB Output is correct
12 Correct 88 ms 156788 KB Output is correct
13 Correct 229 ms 156872 KB Output is correct
14 Correct 237 ms 156916 KB Output is correct
15 Correct 120 ms 156812 KB Output is correct
16 Correct 110 ms 156740 KB Output is correct
17 Correct 109 ms 156924 KB Output is correct
18 Correct 90 ms 156904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 104 ms 156876 KB Output is correct
2 Correct 117 ms 157444 KB Output is correct
3 Correct 286 ms 157284 KB Output is correct
4 Correct 121 ms 156876 KB Output is correct
5 Correct 202 ms 157172 KB Output is correct
6 Correct 107 ms 156860 KB Output is correct
7 Correct 109 ms 156892 KB Output is correct
8 Correct 121 ms 156804 KB Output is correct
9 Correct 244 ms 157300 KB Output is correct
10 Correct 297 ms 157436 KB Output is correct
11 Correct 280 ms 157124 KB Output is correct
12 Correct 163 ms 156804 KB Output is correct
13 Correct 96 ms 156880 KB Output is correct
14 Correct 121 ms 156812 KB Output is correct
15 Correct 241 ms 157096 KB Output is correct
16 Correct 117 ms 157508 KB Output is correct
17 Correct 243 ms 156808 KB Output is correct
18 Correct 236 ms 157508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 260 ms 157556 KB Output is correct
2 Correct 308 ms 157568 KB Output is correct
3 Correct 322 ms 157792 KB Output is correct
4 Correct 199 ms 157760 KB Output is correct
5 Correct 163 ms 158580 KB Output is correct
6 Correct 259 ms 157800 KB Output is correct
7 Correct 217 ms 158032 KB Output is correct
8 Correct 258 ms 157636 KB Output is correct
9 Correct 260 ms 157476 KB Output is correct
10 Correct 196 ms 156960 KB Output is correct
11 Correct 161 ms 157124 KB Output is correct
12 Correct 227 ms 157068 KB Output is correct
13 Correct 287 ms 158020 KB Output is correct
14 Correct 184 ms 158152 KB Output is correct
15 Correct 237 ms 157064 KB Output is correct
16 Correct 268 ms 157064 KB Output is correct
17 Correct 243 ms 157236 KB Output is correct
18 Correct 309 ms 157508 KB Output is correct
19 Correct 112 ms 157036 KB Output is correct
20 Correct 305 ms 157764 KB Output is correct
21 Correct 213 ms 158144 KB Output is correct
22 Correct 345 ms 158444 KB Output is correct
23 Correct 162 ms 157992 KB Output is correct
24 Correct 132 ms 157884 KB Output is correct
25 Correct 229 ms 157964 KB Output is correct
26 Correct 197 ms 157704 KB Output is correct
27 Correct 328 ms 158068 KB Output is correct
28 Correct 125 ms 157892 KB Output is correct
29 Correct 303 ms 158472 KB Output is correct
30 Correct 271 ms 158404 KB Output is correct
31 Correct 147 ms 157704 KB Output is correct
32 Correct 161 ms 157764 KB Output is correct
33 Correct 120 ms 157760 KB Output is correct
34 Correct 234 ms 158004 KB Output is correct
35 Correct 126 ms 157880 KB Output is correct
36 Correct 324 ms 158360 KB Output is correct
37 Correct 166 ms 158532 KB Output is correct
38 Correct 261 ms 157828 KB Output is correct
39 Correct 145 ms 157872 KB Output is correct
40 Correct 227 ms 157844 KB Output is correct
41 Correct 200 ms 158084 KB Output is correct
42 Correct 276 ms 158024 KB Output is correct