Submission #25867

# Submission time Handle Problem Language Result Execution time Memory
25867 2017-06-24T15:52:34 Z gs14004 Brunhilda’s Birthday (BOI13_brunhilda) C++11
100 / 100
463 ms 80144 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;
const int mod = 1e9 + 7;

int n, q;
int nxt[10000005];
int dp[10000005];

int main(){
	scanf("%d %d",&n,&q);
	for(int i=1; i<=n; i++){
		int x;
		scanf("%d",&x);
		for(int j=x; j-1<=10000000; j+=x){
			nxt[j-1] = x-1;
		}
		nxt[10000000] = max(nxt[10000000], 10000000 % x);
	}
	for(int i=10000000; i; i--) nxt[i] = max(nxt[i], nxt[i+1] - 1);
	for(int i=1; i<=10000000; i++){
		if(dp[i - nxt[i]] == -1 || nxt[i] == 0) dp[i] = -1;
		else dp[i] = dp[i - nxt[i]] + 1;
	}
	while(q--){
		int x;
		scanf("%d",&x);
		if(dp[x] < 0) puts("oo");
		else printf("%d\n", dp[x]);
	}
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:12:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&q);
                      ^
brunhilda.cpp:15:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&x);
                 ^
brunhilda.cpp:28:17: 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 89 ms 80144 KB Output is correct
2 Correct 89 ms 80144 KB Output is correct
3 Correct 73 ms 80144 KB Output is correct
4 Correct 86 ms 80144 KB Output is correct
5 Correct 89 ms 80144 KB Output is correct
6 Correct 76 ms 80144 KB Output is correct
7 Correct 93 ms 80144 KB Output is correct
8 Correct 99 ms 80144 KB Output is correct
9 Correct 116 ms 80144 KB Output is correct
10 Correct 163 ms 80144 KB Output is correct
11 Correct 143 ms 80144 KB Output is correct
12 Correct 79 ms 80144 KB Output is correct
13 Correct 299 ms 80144 KB Output is correct
14 Correct 309 ms 80144 KB Output is correct
15 Correct 133 ms 80144 KB Output is correct
16 Correct 113 ms 80144 KB Output is correct
17 Correct 109 ms 80144 KB Output is correct
18 Correct 76 ms 80144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 103 ms 80144 KB Output is correct
2 Correct 139 ms 80144 KB Output is correct
3 Correct 409 ms 80144 KB Output is correct
4 Correct 136 ms 80144 KB Output is correct
5 Correct 229 ms 80144 KB Output is correct
6 Correct 119 ms 80144 KB Output is correct
7 Correct 106 ms 80144 KB Output is correct
8 Correct 119 ms 80144 KB Output is correct
9 Correct 316 ms 80144 KB Output is correct
10 Correct 403 ms 80144 KB Output is correct
11 Correct 393 ms 80144 KB Output is correct
12 Correct 213 ms 80144 KB Output is correct
13 Correct 86 ms 80144 KB Output is correct
14 Correct 153 ms 80144 KB Output is correct
15 Correct 309 ms 80144 KB Output is correct
16 Correct 139 ms 80144 KB Output is correct
17 Correct 306 ms 80144 KB Output is correct
18 Correct 326 ms 80144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 323 ms 80144 KB Output is correct
2 Correct 413 ms 80144 KB Output is correct
3 Correct 416 ms 80144 KB Output is correct
4 Correct 233 ms 80144 KB Output is correct
5 Correct 196 ms 80144 KB Output is correct
6 Correct 326 ms 80144 KB Output is correct
7 Correct 296 ms 80144 KB Output is correct
8 Correct 319 ms 80144 KB Output is correct
9 Correct 289 ms 80144 KB Output is correct
10 Correct 253 ms 80144 KB Output is correct
11 Correct 213 ms 80144 KB Output is correct
12 Correct 293 ms 80144 KB Output is correct
13 Correct 383 ms 80144 KB Output is correct
14 Correct 169 ms 80144 KB Output is correct
15 Correct 299 ms 80144 KB Output is correct
16 Correct 353 ms 80144 KB Output is correct
17 Correct 269 ms 80144 KB Output is correct
18 Correct 416 ms 80144 KB Output is correct
19 Correct 113 ms 80144 KB Output is correct
20 Correct 403 ms 80144 KB Output is correct
21 Correct 239 ms 80144 KB Output is correct
22 Correct 459 ms 80144 KB Output is correct
23 Correct 203 ms 80144 KB Output is correct
24 Correct 123 ms 80144 KB Output is correct
25 Correct 273 ms 80144 KB Output is correct
26 Correct 233 ms 80144 KB Output is correct
27 Correct 463 ms 80144 KB Output is correct
28 Correct 123 ms 80144 KB Output is correct
29 Correct 429 ms 80144 KB Output is correct
30 Correct 389 ms 80144 KB Output is correct
31 Correct 153 ms 80144 KB Output is correct
32 Correct 199 ms 80144 KB Output is correct
33 Correct 139 ms 80144 KB Output is correct
34 Correct 286 ms 80144 KB Output is correct
35 Correct 136 ms 80144 KB Output is correct
36 Correct 443 ms 80144 KB Output is correct
37 Correct 179 ms 80144 KB Output is correct
38 Correct 346 ms 80144 KB Output is correct
39 Correct 153 ms 80144 KB Output is correct
40 Correct 279 ms 80144 KB Output is correct
41 Correct 266 ms 80144 KB Output is correct
42 Correct 376 ms 80144 KB Output is correct