Submission #283196

# Submission time Handle Problem Language Result Execution time Memory
283196 2020-08-25T11:06:52 Z theStaticMind Brunhilda’s Birthday (BOI13_brunhilda) C++14
0 / 100
201 ms 262148 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][8];

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int m, q;
	cin >> m >> q;

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

		for(int j = P[i]; j <= 10000000; j += P[i]){
			if(!f[j][0]) f[j][0] = P[i];
			else if(!f[j][1]) f[j][1] = P[i];
			else if(!f[j][2]) f[j][2] = P[i];
			else if(!f[j][3]) f[j][3] = P[i];
			else if(!f[j][4]) f[j][4] = P[i];
			else if(!f[j][5]) f[j][5] = P[i];
			else if(!f[j][6]) f[j][6] = P[i];
			else if(!f[j][7]) f[j][7] = P[i];
			else assert(0);
		}
		ptr.insert({0, P[i]});
	}



	for(int i = 1; i <= 1e7; i++) dp[i] = 1e9;
	
	for(int i = 1; i <= 1e7; i++){
		for(int j = 0; j < 8 && f[i][j]; j++){
			ptr.erase({i - f[i][j], f[i][j]});
			ptr.insert({i, f[i][j]});
		}
		if(ptr.begin()->first != i) dp[i] = dp[ptr.begin()->first] + 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 Runtime error 185 ms 262148 KB Execution killed with signal 9
2 Runtime error 182 ms 262148 KB Execution killed with signal 9
3 Runtime error 183 ms 262148 KB Execution killed with signal 9
4 Runtime error 181 ms 262148 KB Execution killed with signal 9
5 Runtime error 176 ms 262148 KB Execution killed with signal 9
6 Runtime error 181 ms 262148 KB Execution killed with signal 9
7 Runtime error 184 ms 262148 KB Execution killed with signal 9
8 Runtime error 177 ms 262148 KB Execution killed with signal 9
9 Runtime error 182 ms 262148 KB Execution killed with signal 9
10 Runtime error 183 ms 262148 KB Execution killed with signal 9
11 Runtime error 179 ms 262148 KB Execution killed with signal 9
12 Runtime error 179 ms 262148 KB Execution killed with signal 9
13 Runtime error 179 ms 262148 KB Execution killed with signal 9
14 Runtime error 185 ms 262148 KB Execution killed with signal 9
15 Runtime error 186 ms 262148 KB Execution killed with signal 9
16 Runtime error 193 ms 262148 KB Execution killed with signal 9
17 Runtime error 178 ms 262148 KB Execution killed with signal 9
18 Runtime error 179 ms 262148 KB Execution killed with signal 9
# Verdict Execution time Memory Grader output
1 Runtime error 180 ms 262148 KB Execution killed with signal 9
2 Runtime error 188 ms 262148 KB Execution killed with signal 9
3 Runtime error 178 ms 262148 KB Execution killed with signal 9
4 Runtime error 183 ms 262148 KB Execution killed with signal 9
5 Runtime error 183 ms 262148 KB Execution killed with signal 9
6 Runtime error 178 ms 262148 KB Execution killed with signal 9
7 Runtime error 176 ms 262148 KB Execution killed with signal 9
8 Runtime error 180 ms 262148 KB Execution killed with signal 9
9 Runtime error 177 ms 262148 KB Execution killed with signal 9
10 Runtime error 183 ms 262148 KB Execution killed with signal 9
11 Runtime error 186 ms 262148 KB Execution killed with signal 9
12 Runtime error 179 ms 262148 KB Execution killed with signal 9
13 Runtime error 180 ms 262148 KB Execution killed with signal 9
14 Runtime error 176 ms 262144 KB Execution killed with signal 9
15 Runtime error 181 ms 262148 KB Execution killed with signal 9
16 Runtime error 182 ms 262148 KB Execution killed with signal 9
17 Runtime error 179 ms 262148 KB Execution killed with signal 9
18 Runtime error 173 ms 262144 KB Execution killed with signal 9
# Verdict Execution time Memory Grader output
1 Runtime error 180 ms 262148 KB Execution killed with signal 9
2 Runtime error 181 ms 262148 KB Execution killed with signal 9
3 Runtime error 183 ms 262148 KB Execution killed with signal 9
4 Runtime error 174 ms 262144 KB Execution killed with signal 9
5 Runtime error 186 ms 262148 KB Execution killed with signal 9
6 Runtime error 175 ms 262144 KB Execution killed with signal 9
7 Runtime error 178 ms 262148 KB Execution killed with signal 9
8 Runtime error 186 ms 262148 KB Execution killed with signal 9
9 Runtime error 179 ms 262148 KB Execution killed with signal 9
10 Runtime error 176 ms 262148 KB Execution killed with signal 9
11 Runtime error 179 ms 262148 KB Execution killed with signal 9
12 Runtime error 174 ms 262144 KB Execution killed with signal 9
13 Runtime error 178 ms 262148 KB Execution killed with signal 9
14 Runtime error 189 ms 262148 KB Execution killed with signal 9
15 Runtime error 175 ms 262144 KB Execution killed with signal 9
16 Runtime error 178 ms 262148 KB Execution killed with signal 9
17 Runtime error 177 ms 262144 KB Execution killed with signal 9
18 Runtime error 174 ms 262144 KB Execution killed with signal 9
19 Runtime error 174 ms 262148 KB Execution killed with signal 9
20 Runtime error 178 ms 262144 KB Execution killed with signal 9
21 Runtime error 171 ms 262144 KB Execution killed with signal 9
22 Runtime error 186 ms 262144 KB Execution killed with signal 9
23 Runtime error 171 ms 262144 KB Execution killed with signal 9
24 Runtime error 181 ms 262148 KB Execution killed with signal 9
25 Runtime error 182 ms 262148 KB Execution killed with signal 9
26 Runtime error 189 ms 262148 KB Execution killed with signal 9
27 Runtime error 181 ms 262144 KB Execution killed with signal 9
28 Runtime error 178 ms 262144 KB Execution killed with signal 9
29 Runtime error 180 ms 262148 KB Execution killed with signal 9
30 Runtime error 177 ms 262148 KB Execution killed with signal 9
31 Runtime error 178 ms 262148 KB Execution killed with signal 9
32 Runtime error 178 ms 262148 KB Execution killed with signal 9
33 Runtime error 174 ms 262148 KB Execution killed with signal 9
34 Runtime error 181 ms 262148 KB Execution killed with signal 9
35 Runtime error 190 ms 262148 KB Execution killed with signal 9
36 Runtime error 177 ms 262148 KB Execution killed with signal 9
37 Runtime error 186 ms 262148 KB Execution killed with signal 9
38 Runtime error 182 ms 262148 KB Execution killed with signal 9
39 Runtime error 176 ms 262148 KB Execution killed with signal 9
40 Runtime error 182 ms 262148 KB Execution killed with signal 9
41 Runtime error 201 ms 262144 KB Execution killed with signal 9
42 Runtime error 178 ms 262148 KB Execution killed with signal 9