답안 #283181

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
283181 2020-08-25T10:58:45 Z theStaticMind Brunhilda’s Birthday (BOI13_brunhilda) C++14
0 / 100
295 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];

vector<int> f[10000001];

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]){
			f[j].pb(P[i]);
		}
		ptr.insert({0, P[i]});
	}



	for(int i = 1; i <= 1e7; i++) dp[i] = 1e9;
	
	for(int i = 1; i <= 1e7; i++){
		for(auto p : f[i]){
			ptr.erase({i - p, p});
			ptr.insert({i, p});
		}
		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";
	}
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 175 ms 262148 KB Execution killed with signal 9
2 Runtime error 167 ms 262148 KB Execution killed with signal 9
3 Runtime error 183 ms 262144 KB Execution killed with signal 9
4 Runtime error 255 ms 262148 KB Execution killed with signal 9
5 Runtime error 175 ms 262144 KB Execution killed with signal 9
6 Runtime error 200 ms 262148 KB Execution killed with signal 9
7 Runtime error 160 ms 262144 KB Execution killed with signal 9
8 Runtime error 165 ms 262148 KB Execution killed with signal 9
9 Runtime error 169 ms 262148 KB Execution killed with signal 9
10 Runtime error 208 ms 262148 KB Execution killed with signal 9
11 Runtime error 174 ms 262148 KB Execution killed with signal 9
12 Runtime error 231 ms 262148 KB Execution killed with signal 9
13 Runtime error 169 ms 262148 KB Execution killed with signal 9
14 Runtime error 171 ms 262148 KB Execution killed with signal 9
15 Runtime error 178 ms 262148 KB Execution killed with signal 9
16 Runtime error 167 ms 262148 KB Execution killed with signal 9
17 Runtime error 192 ms 262148 KB Execution killed with signal 9
18 Runtime error 243 ms 262144 KB Execution killed with signal 9
# 결과 실행 시간 메모리 Grader output
1 Runtime error 272 ms 262148 KB Execution killed with signal 9
2 Runtime error 195 ms 262144 KB Execution killed with signal 9
3 Runtime error 173 ms 262148 KB Execution killed with signal 9
4 Runtime error 179 ms 262148 KB Execution killed with signal 9
5 Runtime error 166 ms 262148 KB Execution killed with signal 9
6 Runtime error 168 ms 262148 KB Execution killed with signal 9
7 Runtime error 259 ms 262148 KB Execution killed with signal 9
8 Runtime error 179 ms 262148 KB Execution killed with signal 9
9 Runtime error 173 ms 262148 KB Execution killed with signal 9
10 Runtime error 169 ms 262148 KB Execution killed with signal 9
11 Runtime error 168 ms 262148 KB Execution killed with signal 9
12 Runtime error 169 ms 262148 KB Execution killed with signal 9
13 Runtime error 174 ms 262148 KB Execution killed with signal 9
14 Runtime error 179 ms 262148 KB Execution killed with signal 9
15 Runtime error 167 ms 262148 KB Execution killed with signal 9
16 Runtime error 193 ms 262148 KB Execution killed with signal 9
17 Runtime error 168 ms 262144 KB Execution killed with signal 9
18 Runtime error 170 ms 262148 KB Execution killed with signal 9
# 결과 실행 시간 메모리 Grader output
1 Runtime error 169 ms 262148 KB Execution killed with signal 9
2 Runtime error 160 ms 262144 KB Execution killed with signal 9
3 Runtime error 164 ms 262148 KB Execution killed with signal 9
4 Runtime error 166 ms 262148 KB Execution killed with signal 9
5 Runtime error 289 ms 262148 KB Execution killed with signal 9
6 Runtime error 172 ms 262148 KB Execution killed with signal 9
7 Runtime error 194 ms 262148 KB Execution killed with signal 9
8 Runtime error 171 ms 262148 KB Execution killed with signal 9
9 Runtime error 175 ms 262148 KB Execution killed with signal 9
10 Runtime error 167 ms 262144 KB Execution killed with signal 9
11 Runtime error 167 ms 262148 KB Execution killed with signal 9
12 Runtime error 166 ms 262148 KB Execution killed with signal 9
13 Runtime error 172 ms 262148 KB Execution killed with signal 9
14 Runtime error 174 ms 262148 KB Execution killed with signal 9
15 Runtime error 162 ms 262144 KB Execution killed with signal 9
16 Runtime error 167 ms 262148 KB Execution killed with signal 9
17 Runtime error 173 ms 262148 KB Execution killed with signal 9
18 Runtime error 169 ms 262148 KB Execution killed with signal 9
19 Runtime error 168 ms 262148 KB Execution killed with signal 9
20 Runtime error 169 ms 262148 KB Execution killed with signal 9
21 Runtime error 169 ms 262148 KB Execution killed with signal 9
22 Runtime error 166 ms 262148 KB Execution killed with signal 9
23 Runtime error 295 ms 262148 KB Execution killed with signal 9
24 Runtime error 196 ms 262144 KB Execution killed with signal 9
25 Runtime error 171 ms 262148 KB Execution killed with signal 9
26 Runtime error 167 ms 262148 KB Execution killed with signal 9
27 Runtime error 173 ms 262148 KB Execution killed with signal 9
28 Runtime error 172 ms 262144 KB Execution killed with signal 9
29 Runtime error 176 ms 262144 KB Execution killed with signal 9
30 Runtime error 186 ms 262148 KB Execution killed with signal 9
31 Runtime error 177 ms 262148 KB Execution killed with signal 9
32 Runtime error 167 ms 262148 KB Execution killed with signal 9
33 Runtime error 218 ms 262148 KB Execution killed with signal 9
34 Runtime error 184 ms 262148 KB Execution killed with signal 9
35 Runtime error 168 ms 262148 KB Execution killed with signal 9
36 Runtime error 169 ms 262144 KB Execution killed with signal 9
37 Runtime error 294 ms 262148 KB Execution killed with signal 9
38 Runtime error 170 ms 262148 KB Execution killed with signal 9
39 Runtime error 181 ms 262144 KB Execution killed with signal 9
40 Runtime error 171 ms 262148 KB Execution killed with signal 9
41 Runtime error 169 ms 262148 KB Execution killed with signal 9
42 Runtime error 166 ms 262148 KB Execution killed with signal 9