Submission #230229

# Submission time Handle Problem Language Result Execution time Memory
230229 2020-05-09T09:12:21 Z kshitij_sodani Brunhilda’s Birthday (BOI13_brunhilda) C++17
76.3492 / 100
282 ms 79352 KB
#include <iostream>	
#include <bits/stdc++.h>	
using namespace std;	
typedef int64_t llo;	
#define mp make_pair	
#define pb push_back	
#define a first	
#define b second
#define endl '\n'	
int ma[10000001];

int dp[10000001];
//vector<int> fac[10000001];
int main(){	
	memset(ma,0,sizeof(ma));
	ios_base::sync_with_stdio(false);	
	cin.tie(NULL);
	int n,s;
	cin>>n>>s;
	int aa;
	int it[n];
	for(int i=0;i<n;i++){
		cin>>it[i];
	}
	sort(it,it+n);
	for(int i=0;i<n;i++){
		for(int j=it[i];j<10000001;j+=it[i]){
			ma[j-1]=it[i]-1;
		}
	}
	for(int i=10000000-1;i>=0;i--){
		ma[i]=max(ma[i],ma[i+1]-1);
	}
	dp[0]=0;
	for(int j=1;j<10000001;j++){
		if(ma[j]==0){
			dp[j]=-1;
		}
		else if(dp[j-ma[j]]!=-1){
			dp[j]=dp[j-ma[j]]+1;
		}
		else{
			dp[j]=-1;
		}
	}


	while(s--){
		cin>>aa;
		if(dp[aa]==-1){
			cout<<"oo"<<endl;
		}
		else{
			cout<<dp[aa]<<endl;
		}
	}




	

	return 0;	
}
# Verdict Execution time Memory Grader output
1 Correct 112 ms 78584 KB Output is correct
2 Correct 123 ms 78792 KB Output is correct
3 Correct 113 ms 78584 KB Output is correct
4 Correct 103 ms 78584 KB Output is correct
5 Correct 115 ms 78560 KB Output is correct
6 Correct 106 ms 78560 KB Output is correct
7 Correct 114 ms 78584 KB Output is correct
8 Correct 116 ms 78584 KB Output is correct
9 Correct 130 ms 78584 KB Output is correct
10 Correct 144 ms 78584 KB Output is correct
11 Correct 136 ms 78584 KB Output is correct
12 Correct 101 ms 78584 KB Output is correct
13 Correct 211 ms 78564 KB Output is correct
14 Correct 215 ms 78792 KB Output is correct
15 Correct 132 ms 78564 KB Output is correct
16 Correct 120 ms 78584 KB Output is correct
17 Correct 121 ms 78584 KB Output is correct
18 Correct 102 ms 78584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 117 ms 78712 KB Output is correct
2 Correct 128 ms 78920 KB Output is correct
3 Correct 257 ms 78972 KB Output is correct
4 Correct 131 ms 78584 KB Output is correct
5 Correct 187 ms 78840 KB Output is correct
6 Correct 119 ms 78584 KB Output is correct
7 Correct 118 ms 78724 KB Output is correct
8 Correct 131 ms 78584 KB Output is correct
9 Correct 215 ms 78968 KB Output is correct
10 Correct 282 ms 78840 KB Output is correct
11 Incorrect 262 ms 78712 KB Output isn't correct
12 Correct 157 ms 78584 KB Output is correct
13 Correct 111 ms 78600 KB Output is correct
14 Correct 130 ms 78712 KB Output is correct
15 Correct 212 ms 78712 KB Output is correct
16 Correct 129 ms 78968 KB Output is correct
17 Correct 218 ms 78576 KB Output is correct
18 Incorrect 212 ms 78968 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 226 ms 78972 KB Output is correct
2 Correct 256 ms 79020 KB Output is correct
3 Correct 263 ms 78968 KB Output is correct
4 Incorrect 186 ms 78840 KB Output isn't correct
5 Incorrect 160 ms 79224 KB Output isn't correct
6 Correct 231 ms 78968 KB Output is correct
7 Correct 211 ms 79096 KB Output is correct
8 Correct 224 ms 78968 KB Output is correct
9 Correct 222 ms 78844 KB Output is correct
10 Correct 181 ms 78712 KB Output is correct
11 Incorrect 167 ms 78712 KB Output isn't correct
12 Correct 202 ms 78712 KB Output is correct
13 Correct 258 ms 79060 KB Output is correct
14 Correct 170 ms 79224 KB Output is correct
15 Incorrect 214 ms 78840 KB Output isn't correct
16 Correct 233 ms 78712 KB Output is correct
17 Correct 212 ms 78920 KB Output is correct
18 Correct 264 ms 78968 KB Output is correct
19 Incorrect 121 ms 78712 KB Output isn't correct
20 Correct 267 ms 79096 KB Output is correct
21 Incorrect 190 ms 79352 KB Output isn't correct
22 Correct 277 ms 79220 KB Output is correct
23 Correct 162 ms 78968 KB Output is correct
24 Correct 138 ms 78840 KB Output is correct
25 Incorrect 199 ms 78968 KB Output isn't correct
26 Incorrect 188 ms 78968 KB Output isn't correct
27 Correct 280 ms 79096 KB Output is correct
28 Incorrect 139 ms 78968 KB Output isn't correct
29 Correct 271 ms 79352 KB Output is correct
30 Correct 253 ms 79096 KB Output is correct
31 Correct 151 ms 78844 KB Output is correct
32 Incorrect 170 ms 78908 KB Output isn't correct
33 Incorrect 131 ms 78840 KB Output isn't correct
34 Correct 206 ms 79100 KB Output is correct
35 Incorrect 139 ms 78968 KB Output isn't correct
36 Correct 270 ms 79224 KB Output is correct
37 Incorrect 157 ms 79224 KB Output isn't correct
38 Correct 235 ms 78968 KB Output is correct
39 Incorrect 147 ms 78968 KB Output isn't correct
40 Correct 207 ms 78968 KB Output is correct
41 Correct 194 ms 79096 KB Output is correct
42 Incorrect 242 ms 78968 KB Output isn't correct