Submission #36500

# Submission time Handle Problem Language Result Execution time Memory
36500 2017-12-10T03:19:08 Z cheater2k Brunhilda’s Birthday (BOI13_brunhilda) C++14
20 / 100
46 ms 9828 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() {
	scanf("%d %d", &nprime, &nquery);
	for (int i = 1; i <= MAX; ++i) dp[i] = inf;
	for (int i = 1; i <= nprime; ++i) {
		int p; scanf("%d", &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");
	}
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:12:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &nprime, &nquery);
                                  ^
brunhilda.cpp:15:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int p; scanf("%d", &p);
                         ^
# Verdict Execution time Memory Grader output
1 Correct 13 ms 9828 KB Output is correct
2 Correct 9 ms 9828 KB Output is correct
3 Correct 6 ms 9828 KB Output is correct
4 Correct 19 ms 9828 KB Output is correct
5 Correct 13 ms 9828 KB Output is correct
6 Correct 16 ms 9828 KB Output is correct
7 Correct 9 ms 9828 KB Output is correct
8 Correct 6 ms 9828 KB Output is correct
9 Correct 13 ms 9828 KB Output is correct
10 Correct 13 ms 9828 KB Output is correct
11 Correct 23 ms 9828 KB Output is correct
12 Correct 6 ms 9828 KB Output is correct
13 Correct 29 ms 9828 KB Output is correct
14 Correct 16 ms 9828 KB Output is correct
15 Correct 13 ms 9828 KB Output is correct
16 Correct 13 ms 9828 KB Output is correct
17 Correct 23 ms 9828 KB Output is correct
18 Correct 46 ms 9828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 19 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 33 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 6 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 16 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 6 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 6 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 9 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 23 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 29 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 19 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 9 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 6 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 13 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 16 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 13 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 13 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 19 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 13 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 16 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 16 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 9 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 19 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 13 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 23 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 23 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 16 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 16 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 9 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 6 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 16 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 9 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 9 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 19 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 19 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 19 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 9 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 16 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
21 Runtime error 6 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Runtime error 29 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
23 Runtime error 6 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
24 Runtime error 9 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Runtime error 9 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Runtime error 9 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
27 Runtime error 19 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
28 Runtime error 6 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
29 Runtime error 23 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
30 Runtime error 16 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
31 Runtime error 9 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Runtime error 13 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
33 Runtime error 13 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
34 Runtime error 23 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
35 Runtime error 6 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
36 Runtime error 26 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
37 Runtime error 19 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
38 Runtime error 23 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
39 Runtime error 13 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
40 Runtime error 13 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
41 Runtime error 19 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
42 Runtime error 13 ms 9828 KB Execution killed with signal 11 (could be triggered by violating memory limits)