Submission #318105

# Submission time Handle Problem Language Result Execution time Memory
318105 2020-10-31T13:08:12 Z shivensinha4 Brunhilda’s Birthday (BOI13_brunhilda) C++17
74.127 / 100
339 ms 80228 KB
#include "bits/stdc++.h"
using namespace std; 
#define for_(i, s, e) for (int i = s; i < (int) e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl '\n'

const int MXN = 1e7;
int jmp[MXN+2], ans[MXN+2];

int main() {
	#ifdef shiven
	freopen("test.in", "r", stdin);
	#endif
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int m, q; cin >> m >> q;
	for_(i, 0, m) {
		int k; cin >> k;
		for (int j = k; j <= MXN; j += k) {
			jmp[j-1] = max(jmp[j-1], k-1);
		}
	}
	
	for (int i = MXN; i >= 0; i--) jmp[i] = max(jmp[i], jmp[i+1]-1);
	
	for_(i, 1, MXN+1) if (jmp[i]) ans[i] = ans[i-jmp[i]]+1;
	
	for_(i, 0, q) {
		int k; cin >> k;
		if (ans[k]) cout << ans[k];
		else cout << "oo";
		cout << endl;
	}

	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 105 ms 78564 KB Output isn't correct
2 Correct 130 ms 78564 KB Output is correct
3 Correct 124 ms 78692 KB Output is correct
4 Correct 112 ms 78692 KB Output is correct
5 Correct 128 ms 78564 KB Output is correct
6 Incorrect 105 ms 78564 KB Output isn't correct
7 Correct 118 ms 78572 KB Output is correct
8 Correct 124 ms 78560 KB Output is correct
9 Correct 138 ms 78568 KB Output is correct
10 Correct 157 ms 78692 KB Output is correct
11 Correct 156 ms 78692 KB Output is correct
12 Correct 106 ms 78612 KB Output is correct
13 Correct 260 ms 78572 KB Output is correct
14 Correct 256 ms 78692 KB Output is correct
15 Correct 143 ms 78564 KB Output is correct
16 Correct 132 ms 78564 KB Output is correct
17 Correct 134 ms 78688 KB Output is correct
18 Correct 109 ms 78568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 127 ms 78840 KB Output is correct
2 Correct 145 ms 79332 KB Output is correct
3 Correct 303 ms 78948 KB Output is correct
4 Correct 149 ms 78564 KB Output is correct
5 Correct 232 ms 78820 KB Output is correct
6 Correct 132 ms 78564 KB Output is correct
7 Correct 125 ms 78692 KB Output is correct
8 Correct 144 ms 78564 KB Output is correct
9 Correct 264 ms 79076 KB Output is correct
10 Correct 311 ms 78948 KB Output is correct
11 Incorrect 302 ms 78692 KB Output isn't correct
12 Correct 175 ms 78564 KB Output is correct
13 Correct 112 ms 78564 KB Output is correct
14 Correct 144 ms 78692 KB Output is correct
15 Correct 251 ms 78692 KB Output is correct
16 Correct 139 ms 79348 KB Output is correct
17 Correct 256 ms 78692 KB Output is correct
18 Incorrect 253 ms 79076 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 267 ms 79204 KB Output is correct
2 Correct 320 ms 78948 KB Output is correct
3 Correct 323 ms 79460 KB Output is correct
4 Incorrect 206 ms 79460 KB Output isn't correct
5 Incorrect 179 ms 80228 KB Output isn't correct
6 Correct 277 ms 79588 KB Output is correct
7 Correct 236 ms 79972 KB Output is correct
8 Correct 262 ms 79204 KB Output is correct
9 Correct 264 ms 79460 KB Output is correct
10 Correct 210 ms 78700 KB Output is correct
11 Incorrect 185 ms 78820 KB Output isn't correct
12 Correct 240 ms 78820 KB Output is correct
13 Correct 304 ms 79716 KB Output is correct
14 Correct 188 ms 79204 KB Output is correct
15 Incorrect 251 ms 78964 KB Output isn't correct
16 Correct 279 ms 78820 KB Output is correct
17 Correct 253 ms 78820 KB Output is correct
18 Correct 323 ms 79076 KB Output is correct
19 Incorrect 125 ms 78820 KB Output isn't correct
20 Correct 317 ms 79328 KB Output is correct
21 Incorrect 214 ms 80100 KB Output isn't correct
22 Correct 331 ms 80100 KB Output is correct
23 Correct 174 ms 79716 KB Output is correct
24 Correct 143 ms 79588 KB Output is correct
25 Incorrect 227 ms 79716 KB Output isn't correct
26 Incorrect 209 ms 79716 KB Output isn't correct
27 Correct 339 ms 79588 KB Output is correct
28 Incorrect 139 ms 79716 KB Output isn't correct
29 Correct 314 ms 80100 KB Output is correct
30 Correct 295 ms 80096 KB Output is correct
31 Correct 161 ms 79588 KB Output is correct
32 Incorrect 175 ms 79460 KB Output isn't correct
33 Incorrect 133 ms 79588 KB Output isn't correct
34 Correct 240 ms 79716 KB Output is correct
35 Incorrect 147 ms 79716 KB Output isn't correct
36 Correct 324 ms 79972 KB Output is correct
37 Incorrect 170 ms 80228 KB Output isn't correct
38 Correct 269 ms 79716 KB Output is correct
39 Incorrect 157 ms 79588 KB Output isn't correct
40 Correct 237 ms 79592 KB Output is correct
41 Correct 214 ms 79844 KB Output is correct
42 Incorrect 288 ms 79844 KB Output isn't correct