Submission #334745

# Submission time Handle Problem Language Result Execution time Memory
334745 2020-12-10T00:17:19 Z Fischer Brunhilda’s Birthday (BOI13_brunhilda) C++14
100 / 100
372 ms 95084 KB
#include <bits/stdc++.h>
using namespace std;

const int maxn = 1.2e7 + 10;
int dp[maxn];
int link[maxn];

int main() {
	int m, q;
	scanf("%d%d", &m, &q);
	for (int i=0; i<m; ++i) {
		int x;
		scanf("%d", &x);
		for (int j=x-1; j<maxn; j+=x) {
			link[j] = x-1;
		}
	}
	for (int i = maxn-2; i >= 1; --i) {
		if (link[i] < link[i+1] - 1) {
			link[i] = link[i+1] - 1;
		}
	}
	const int inf = 1e9;
	for (int i = 1; i < maxn; ++i) {
			if (link[i] == 0) dp[i] = inf;
			else dp[i] = min(inf, dp[i - link[i]] + 1);
	}
	while (q--) {
		int n;
		scanf("%d", &n);
		if (dp[n] > n) puts("oo\n");
		else printf("%d\n", dp[n]);
	}
	return 0;
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |  scanf("%d%d", &m, &q);
      |  ~~~~~^~~~~~~~~~~~~~~~
brunhilda.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |   scanf("%d", &x);
      |   ~~~~~^~~~~~~~~~
brunhilda.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   30 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 119 ms 94336 KB Output is correct
2 Correct 136 ms 94396 KB Output is correct
3 Correct 122 ms 94188 KB Output is correct
4 Correct 112 ms 94316 KB Output is correct
5 Correct 132 ms 94316 KB Output is correct
6 Correct 121 ms 94316 KB Output is correct
7 Correct 122 ms 94188 KB Output is correct
8 Correct 136 ms 94360 KB Output is correct
9 Correct 151 ms 94336 KB Output is correct
10 Correct 170 ms 94316 KB Output is correct
11 Correct 162 ms 94316 KB Output is correct
12 Correct 112 ms 94188 KB Output is correct
13 Correct 264 ms 94316 KB Output is correct
14 Correct 269 ms 94444 KB Output is correct
15 Correct 145 ms 94316 KB Output is correct
16 Correct 135 ms 94316 KB Output is correct
17 Correct 136 ms 94316 KB Output is correct
18 Correct 113 ms 94444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 132 ms 94316 KB Output is correct
2 Correct 152 ms 94444 KB Output is correct
3 Correct 330 ms 94468 KB Output is correct
4 Correct 149 ms 94316 KB Output is correct
5 Correct 237 ms 94444 KB Output is correct
6 Correct 133 ms 94316 KB Output is correct
7 Correct 147 ms 94316 KB Output is correct
8 Correct 148 ms 94316 KB Output is correct
9 Correct 277 ms 94572 KB Output is correct
10 Correct 330 ms 94572 KB Output is correct
11 Correct 317 ms 94444 KB Output is correct
12 Correct 188 ms 94316 KB Output is correct
13 Correct 118 ms 94316 KB Output is correct
14 Correct 151 ms 94316 KB Output is correct
15 Correct 270 ms 94572 KB Output is correct
16 Correct 155 ms 94444 KB Output is correct
17 Correct 283 ms 94316 KB Output is correct
18 Correct 278 ms 94700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 283 ms 94616 KB Output is correct
2 Correct 344 ms 94700 KB Output is correct
3 Correct 344 ms 94828 KB Output is correct
4 Correct 222 ms 94700 KB Output is correct
5 Correct 191 ms 94812 KB Output is correct
6 Correct 288 ms 94828 KB Output is correct
7 Correct 263 ms 94572 KB Output is correct
8 Correct 282 ms 94700 KB Output is correct
9 Correct 281 ms 94572 KB Output is correct
10 Correct 226 ms 94444 KB Output is correct
11 Correct 195 ms 94444 KB Output is correct
12 Correct 254 ms 94572 KB Output is correct
13 Correct 328 ms 94828 KB Output is correct
14 Correct 207 ms 95084 KB Output is correct
15 Correct 265 ms 94596 KB Output is correct
16 Correct 294 ms 94572 KB Output is correct
17 Correct 273 ms 94572 KB Output is correct
18 Correct 338 ms 94572 KB Output is correct
19 Correct 133 ms 94572 KB Output is correct
20 Correct 339 ms 94700 KB Output is correct
21 Correct 226 ms 95084 KB Output is correct
22 Correct 361 ms 94828 KB Output is correct
23 Correct 189 ms 94700 KB Output is correct
24 Correct 158 ms 94828 KB Output is correct
25 Correct 246 ms 94832 KB Output is correct
26 Correct 221 ms 94700 KB Output is correct
27 Correct 372 ms 94700 KB Output is correct
28 Correct 152 ms 94828 KB Output is correct
29 Correct 347 ms 94700 KB Output is correct
30 Correct 315 ms 94828 KB Output is correct
31 Correct 175 ms 94700 KB Output is correct
32 Correct 194 ms 94980 KB Output is correct
33 Correct 143 ms 94700 KB Output is correct
34 Correct 259 ms 94572 KB Output is correct
35 Correct 160 ms 94956 KB Output is correct
36 Correct 349 ms 94828 KB Output is correct
37 Correct 193 ms 94820 KB Output is correct
38 Correct 288 ms 94828 KB Output is correct
39 Correct 169 ms 94912 KB Output is correct
40 Correct 255 ms 94700 KB Output is correct
41 Correct 233 ms 94572 KB Output is correct
42 Correct 312 ms 94980 KB Output is correct