Submission #163961

# Submission time Handle Problem Language Result Execution time Memory
163961 2019-11-16T12:18:03 Z luciocf Brunhilda’s Birthday (BOI13_brunhilda) C++14
20 / 100
663 ms 1016 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 1e4+10;

int a[maxn];

int dp[maxn];

int main(void)
{
	int n, q;
	scanf("%d %d", &n, &q);

	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);

	sort(a+1, a+n+1);

	for (int i = 1; i < maxn; i++)
		dp[i] = 1e9+10;

	for (int i = 1; i < maxn; i++)
		for (int j = n; j >= 1; j--)
			dp[i] = min(dp[i], 1+dp[i-(i%a[j])]);

	for (int i = 1; i <= q; i++)
	{
		int x;
		scanf("%d", &x);

		if (dp[x] != 1e9+10) printf("%d\n", dp[x]);
		else printf("oo\n");
	}
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &q);
  ~~~~~^~~~~~~~~~~~~~~~~
brunhilda.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]);
   ~~~~~^~~~~~~~~~~~~
brunhilda.cpp:31:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &x);
   ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 9 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 4 ms 376 KB Output is correct
12 Correct 8 ms 376 KB Output is correct
13 Correct 56 ms 376 KB Output is correct
14 Correct 58 ms 504 KB Output is correct
15 Correct 4 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 7 ms 376 KB Output is correct
18 Correct 9 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 663 ms 732 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Execution timed out 4 ms 376 KB Time limit exceeded (wall clock)
3 Execution timed out 4 ms 376 KB Time limit exceeded (wall clock)
4 Runtime error 169 ms 508 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Execution timed out 4 ms 376 KB Time limit exceeded (wall clock)
6 Runtime error 66 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 646 ms 764 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 57 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Execution timed out 4 ms 376 KB Time limit exceeded (wall clock)
10 Execution timed out 4 ms 376 KB Time limit exceeded (wall clock)
11 Execution timed out 4 ms 376 KB Time limit exceeded (wall clock)
12 Runtime error 116 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 160 ms 540 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 170 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Execution timed out 4 ms 632 KB Time limit exceeded (wall clock)
16 Execution timed out 4 ms 632 KB Time limit exceeded (wall clock)
17 Runtime error 164 ms 532 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Execution timed out 4 ms 376 KB Time limit exceeded (wall clock)
# Verdict Execution time Memory Grader output
1 Execution timed out 4 ms 632 KB Time limit exceeded (wall clock)
2 Execution timed out 4 ms 376 KB Time limit exceeded (wall clock)
3 Execution timed out 4 ms 632 KB Time limit exceeded (wall clock)
4 Runtime error 184 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Execution timed out 4 ms 376 KB Time limit exceeded (wall clock)
6 Runtime error 437 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Execution timed out 4 ms 376 KB Time limit exceeded (wall clock)
8 Execution timed out 4 ms 376 KB Time limit exceeded (wall clock)
9 Execution timed out 4 ms 376 KB Time limit exceeded (wall clock)
10 Runtime error 324 ms 548 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 238 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 318 ms 544 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Execution timed out 4 ms 612 KB Time limit exceeded (wall clock)
14 Runtime error 4 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 296 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 382 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Execution timed out 4 ms 636 KB Time limit exceeded (wall clock)
18 Execution timed out 4 ms 376 KB Time limit exceeded (wall clock)
19 Runtime error 276 ms 576 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Execution timed out 4 ms 376 KB Time limit exceeded (wall clock)
21 Runtime error 8 ms 636 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Execution timed out 4 ms 376 KB Time limit exceeded (wall clock)
23 Execution timed out 4 ms 376 KB Time limit exceeded (wall clock)
24 Runtime error 63 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Runtime error 161 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Runtime error 206 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
27 Execution timed out 4 ms 504 KB Time limit exceeded (wall clock)
28 Runtime error 57 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
29 Execution timed out 4 ms 376 KB Time limit exceeded (wall clock)
30 Execution timed out 4 ms 380 KB Time limit exceeded (wall clock)
31 Runtime error 239 ms 636 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Runtime error 157 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
33 Runtime error 69 ms 560 KB Execution killed with signal 11 (could be triggered by violating memory limits)
34 Execution timed out 4 ms 632 KB Time limit exceeded (wall clock)
35 Runtime error 110 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
36 Execution timed out 4 ms 376 KB Time limit exceeded (wall clock)
37 Execution timed out 4 ms 376 KB Time limit exceeded (wall clock)
38 Runtime error 439 ms 1016 KB Execution killed with signal 11 (could be triggered by violating memory limits)
39 Runtime error 125 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
40 Runtime error 507 ms 568 KB Execution killed with signal 11 (could be triggered by violating memory limits)
41 Execution timed out 4 ms 376 KB Time limit exceeded (wall clock)
42 Runtime error 162 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)