답안 #36499

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
36499 2017-12-10T03:17:57 Z cheater2k Brunhilda’s Birthday (BOI13_brunhilda) C++14
20 / 100
29 ms 9988 KB
#include <bits/stdc++.h>
using namespace std;

const int MAX = 1000000;
const int inf = 1e9 + 10;

int nprime, nquery;
int maxdiv[MAX + 5];
int dp[MAX + 5];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> nprime >> nquery;
	for (int i = 1; i <= MAX; ++i) dp[i] = inf;
	for (int i = 1; i <= nprime; ++i) {
		int p; cin >> p;
		for (int j = 0; j <= MAX; j += p) maxdiv[j] = p;
	}
	
	int cur = 0;
	for (int i = 1; i <= MAX; ++i) {
		while(cur < i) {
			if (!maxdiv[cur] || cur + maxdiv[cur] <= i) ++cur;
			else break;
		}
		if (cur == i) continue;
		dp[i] = min(dp[i], dp[cur] + 1);
	}

	while(nquery--) {
		int n; cin >> n;
		if (dp[n] != inf) printf("%d\n", dp[n]);
		else printf("oo\n");
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 9988 KB Output is correct
2 Correct 9 ms 9988 KB Output is correct
3 Correct 6 ms 9988 KB Output is correct
4 Correct 6 ms 9988 KB Output is correct
5 Correct 16 ms 9988 KB Output is correct
6 Correct 6 ms 9988 KB Output is correct
7 Correct 13 ms 9988 KB Output is correct
8 Correct 9 ms 9988 KB Output is correct
9 Correct 13 ms 9988 KB Output is correct
10 Correct 13 ms 9988 KB Output is correct
11 Correct 9 ms 9988 KB Output is correct
12 Correct 6 ms 9988 KB Output is correct
13 Correct 9 ms 9988 KB Output is correct
14 Correct 9 ms 9988 KB Output is correct
15 Correct 6 ms 9988 KB Output is correct
16 Correct 9 ms 9988 KB Output is correct
17 Correct 13 ms 9988 KB Output is correct
18 Correct 9 ms 9988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 9 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 16 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 9 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 9 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 3 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 6 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 13 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 16 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 19 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 19 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 13 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 6 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 9 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 13 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 13 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 9 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 19 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 19 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 13 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 26 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 6 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 16 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 13 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 19 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 16 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 13 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 13 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 9 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 9 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 26 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 13 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 16 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 16 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 23 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 13 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 13 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 19 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
21 Runtime error 9 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Runtime error 29 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
23 Runtime error 13 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
24 Runtime error 6 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Runtime error 13 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Runtime error 9 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
27 Runtime error 26 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
28 Runtime error 9 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
29 Runtime error 16 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
30 Runtime error 19 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
31 Runtime error 6 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Runtime error 16 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
33 Runtime error 6 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
34 Runtime error 16 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
35 Runtime error 13 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
36 Runtime error 16 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
37 Runtime error 16 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
38 Runtime error 13 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
39 Runtime error 6 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
40 Runtime error 9 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
41 Runtime error 13 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
42 Runtime error 9 ms 9988 KB Execution killed with signal 11 (could be triggered by violating memory limits)