Submission #121592

# Submission time Handle Problem Language Result Execution time Memory
121592 2019-06-26T20:01:59 Z Adhyyan1252 Brunhilda’s Birthday (BOI13_brunhilda) C++11
100 / 100
441 ms 80252 KB
#include<bits/stdc++.h>

using namespace std;

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	int m, q; cin>>m>>q;
	vector<int> p(m);
	for(int i = 0; i < m; i++){
		cin>>p[i];
	}
	int mx = 1e7+3;
	vector<int> dp(mx, 0);
	for(int i: p){
		for(int j = i-1; j < mx; j += i){
			dp[j] = i-1;
		}
	}
	//cout<<"DONE"<<endl;
	int bestMod = 0;
	for(int i: p) {
		bestMod = max(bestMod, (mx-1)%i);
	}
	for(int i = mx-1; i >= 2; i--){
		bestMod = max(bestMod, dp[i]);
		assert(bestMod >= 0);
		dp[i] = bestMod;
		bestMod--;
	}
	//cout<<"DONE"<<endl;
	vector<int> ans(mx, 2*mx);
	//cout<<"DONE"<<endl;
	ans[0] = 0;
	for(int i = 1; i < p.back(); i++){
		ans[i] = 1;
	}
	//cout<<"DONE"<<endl;
	for(int i = p.back(); i < mx; i++){
		assert(i >= dp[i]);
		ans[i] = ans[i-dp[i]]+1;
	}
	for(int i = 0; i < q; i++){
		int v; cin>>v;
		if(ans[v] > mx){
			cout<<"oo\n";
		}else{
			cout<<ans[v]<<"\n";
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 110 ms 78712 KB Output is correct
2 Correct 144 ms 78584 KB Output is correct
3 Correct 120 ms 78816 KB Output is correct
4 Correct 114 ms 78716 KB Output is correct
5 Correct 126 ms 78684 KB Output is correct
6 Correct 109 ms 78576 KB Output is correct
7 Correct 118 ms 78584 KB Output is correct
8 Correct 127 ms 78672 KB Output is correct
9 Correct 148 ms 78584 KB Output is correct
10 Correct 178 ms 78556 KB Output is correct
11 Correct 171 ms 78600 KB Output is correct
12 Correct 103 ms 78556 KB Output is correct
13 Correct 310 ms 78584 KB Output is correct
14 Correct 314 ms 78712 KB Output is correct
15 Correct 155 ms 78584 KB Output is correct
16 Correct 140 ms 78712 KB Output is correct
17 Correct 145 ms 78708 KB Output is correct
18 Correct 109 ms 78656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 128 ms 78712 KB Output is correct
2 Correct 147 ms 79352 KB Output is correct
3 Correct 397 ms 79224 KB Output is correct
4 Correct 160 ms 78712 KB Output is correct
5 Correct 262 ms 79300 KB Output is correct
6 Correct 137 ms 78584 KB Output is correct
7 Correct 126 ms 78840 KB Output is correct
8 Correct 159 ms 78612 KB Output is correct
9 Correct 321 ms 79396 KB Output is correct
10 Correct 386 ms 79352 KB Output is correct
11 Correct 391 ms 79084 KB Output is correct
12 Correct 212 ms 78840 KB Output is correct
13 Correct 123 ms 78684 KB Output is correct
14 Correct 173 ms 78628 KB Output is correct
15 Correct 310 ms 79152 KB Output is correct
16 Correct 141 ms 79392 KB Output is correct
17 Correct 321 ms 78712 KB Output is correct
18 Correct 324 ms 79224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 316 ms 79452 KB Output is correct
2 Correct 402 ms 79320 KB Output is correct
3 Correct 410 ms 79744 KB Output is correct
4 Correct 248 ms 79632 KB Output is correct
5 Correct 173 ms 80252 KB Output is correct
6 Correct 330 ms 79608 KB Output is correct
7 Correct 288 ms 79632 KB Output is correct
8 Correct 318 ms 79328 KB Output is correct
9 Correct 299 ms 79324 KB Output is correct
10 Correct 261 ms 78840 KB Output is correct
11 Correct 221 ms 78856 KB Output is correct
12 Correct 296 ms 78968 KB Output is correct
13 Correct 387 ms 79864 KB Output is correct
14 Correct 207 ms 79908 KB Output is correct
15 Correct 307 ms 79096 KB Output is correct
16 Correct 349 ms 79096 KB Output is correct
17 Correct 317 ms 79224 KB Output is correct
18 Correct 400 ms 79316 KB Output is correct
19 Correct 131 ms 78712 KB Output is correct
20 Correct 398 ms 79452 KB Output is correct
21 Correct 247 ms 79992 KB Output is correct
22 Correct 407 ms 80120 KB Output is correct
23 Correct 179 ms 79996 KB Output is correct
24 Correct 151 ms 79580 KB Output is correct
25 Correct 279 ms 79864 KB Output is correct
26 Correct 237 ms 79580 KB Output is correct
27 Correct 441 ms 79612 KB Output is correct
28 Correct 154 ms 79736 KB Output is correct
29 Correct 379 ms 80152 KB Output is correct
30 Correct 354 ms 80024 KB Output is correct
31 Correct 173 ms 79608 KB Output is correct
32 Correct 203 ms 79808 KB Output is correct
33 Correct 139 ms 79612 KB Output is correct
34 Correct 288 ms 79596 KB Output is correct
35 Correct 159 ms 79736 KB Output is correct
36 Correct 403 ms 80120 KB Output is correct
37 Correct 171 ms 80140 KB Output is correct
38 Correct 327 ms 79736 KB Output is correct
39 Correct 169 ms 79676 KB Output is correct
40 Correct 273 ms 79640 KB Output is correct
41 Correct 239 ms 79632 KB Output is correct
42 Correct 349 ms 79844 KB Output is correct