Submission #283205

# Submission time Handle Problem Language Result Execution time Memory
283205 2020-08-25T11:15:56 Z theStaticMind Brunhilda’s Birthday (BOI13_brunhilda) C++14
100 / 100
285 ms 80760 KB
#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
//#define int long long int
using namespace std;

int dp[10000001];

int f[10000001];

int32_t main(){ 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
  
	int m, q;
	cin >> m >> q;

	vector<int> P(m);
	for(int i = 0; i < m; i++){
		cin >> P[i];

		for(int j = 0; j <= 10000000; j += P[i]){
			f[j] = P[i];
		}
	}



	for(int i = 1; i <= 1e7; i++) dp[i] = 1e9;

	int l = 0;
	
	for(int i = 1; i <= 1e7; i++){
		while(l + f[l] <= i && l <= i) l++;
		if(l != i) dp[i] = dp[l] + 1;
		else break;

	}

	while(q--){
		int n;
		cin >> n;

		if(dp[n] >= 1e9) cout << "oo\n";
		else cout << dp[n] << "\n";
	}
}
# Verdict Execution time Memory Grader output
1 Correct 53 ms 78584 KB Output is correct
2 Correct 101 ms 78684 KB Output is correct
3 Correct 59 ms 78584 KB Output is correct
4 Correct 80 ms 78712 KB Output is correct
5 Correct 99 ms 78584 KB Output is correct
6 Correct 50 ms 78584 KB Output is correct
7 Correct 60 ms 78584 KB Output is correct
8 Correct 69 ms 78584 KB Output is correct
9 Correct 117 ms 78712 KB Output is correct
10 Correct 128 ms 78584 KB Output is correct
11 Correct 124 ms 78584 KB Output is correct
12 Correct 78 ms 78584 KB Output is correct
13 Correct 203 ms 78584 KB Output is correct
14 Correct 207 ms 78712 KB Output is correct
15 Correct 112 ms 78584 KB Output is correct
16 Correct 102 ms 78680 KB Output is correct
17 Correct 106 ms 78716 KB Output is correct
18 Correct 90 ms 78712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 92 ms 78864 KB Output is correct
2 Correct 105 ms 79736 KB Output is correct
3 Correct 246 ms 79352 KB Output is correct
4 Correct 109 ms 78584 KB Output is correct
5 Correct 181 ms 79224 KB Output is correct
6 Correct 101 ms 78584 KB Output is correct
7 Correct 90 ms 78712 KB Output is correct
8 Correct 110 ms 78712 KB Output is correct
9 Correct 204 ms 79352 KB Output is correct
10 Correct 246 ms 79352 KB Output is correct
11 Correct 244 ms 79096 KB Output is correct
12 Correct 140 ms 78584 KB Output is correct
13 Correct 82 ms 78640 KB Output is correct
14 Correct 113 ms 78584 KB Output is correct
15 Correct 203 ms 79096 KB Output is correct
16 Correct 105 ms 79736 KB Output is correct
17 Correct 206 ms 78712 KB Output is correct
18 Correct 211 ms 79736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 214 ms 79560 KB Output is correct
2 Correct 257 ms 79352 KB Output is correct
3 Correct 258 ms 79736 KB Output is correct
4 Correct 167 ms 79608 KB Output is correct
5 Correct 137 ms 80760 KB Output is correct
6 Correct 220 ms 79736 KB Output is correct
7 Correct 194 ms 80376 KB Output is correct
8 Correct 213 ms 79564 KB Output is correct
9 Correct 214 ms 79480 KB Output is correct
10 Correct 168 ms 78840 KB Output is correct
11 Correct 147 ms 78840 KB Output is correct
12 Correct 191 ms 78840 KB Output is correct
13 Correct 269 ms 79980 KB Output is correct
14 Correct 164 ms 79992 KB Output is correct
15 Correct 203 ms 78988 KB Output is correct
16 Correct 230 ms 78968 KB Output is correct
17 Correct 208 ms 79224 KB Output is correct
18 Correct 285 ms 79352 KB Output is correct
19 Correct 98 ms 78968 KB Output is correct
20 Correct 265 ms 79736 KB Output is correct
21 Correct 173 ms 79992 KB Output is correct
22 Correct 275 ms 80632 KB Output is correct
23 Correct 143 ms 79992 KB Output is correct
24 Correct 113 ms 79604 KB Output is correct
25 Correct 186 ms 79736 KB Output is correct
26 Correct 173 ms 79620 KB Output is correct
27 Correct 280 ms 80272 KB Output is correct
28 Correct 108 ms 79736 KB Output is correct
29 Correct 263 ms 80760 KB Output is correct
30 Correct 238 ms 80376 KB Output is correct
31 Correct 130 ms 79608 KB Output is correct
32 Correct 144 ms 79608 KB Output is correct
33 Correct 104 ms 79608 KB Output is correct
34 Correct 195 ms 80248 KB Output is correct
35 Correct 114 ms 79736 KB Output is correct
36 Correct 268 ms 80632 KB Output is correct
37 Correct 139 ms 80760 KB Output is correct
38 Correct 224 ms 79736 KB Output is correct
39 Correct 125 ms 79736 KB Output is correct
40 Correct 195 ms 79608 KB Output is correct
41 Correct 183 ms 80248 KB Output is correct
42 Correct 239 ms 79864 KB Output is correct