답안 #60816

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
60816 2018-07-24T17:36:05 Z RezwanArefin01 Brunhilda’s Birthday (BOI13_brunhilda) C++17
100 / 100
632 ms 79524 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> ii; 

const int N = 1e7 + 1; 
const int M = 1e5 + 1; 
int m, q, d[N], p, dp[N]; 

int main(int argc, char const *argv[]) {
#ifdef LOCAL
	freopen("in", "r", stdin);
#endif
	memset(dp, 127, sizeof dp); 
	scanf("%d %d", &m, &q); 
	for(int i = 0; i < m; i++) { 
		scanf("%d", &p); 
		for(int j = 0; j < N; j += p) d[j] = p; 
	}	
	int prv = 0; dp[0] = 0; 
	for(int i = 1; i < N; i++) {
		while(prv < i) {
			if(!d[prv] || prv + d[prv] <= i) ++prv; 
			else break; 
		}
		if(prv == i) break; 
		dp[i] = dp[prv] + 1; 
	}
	while(q--) {
		int x; scanf("%d", &x);
		if(dp[x] >= 2139062143) puts("oo"); 
		else printf("%d\n", dp[x]);
	}
}

Compilation message

brunhilda.cpp: In function 'int main(int, const char**)':
brunhilda.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &m, &q); 
  ~~~~~^~~~~~~~~~~~~~~~~
brunhilda.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &p); 
   ~~~~~^~~~~~~~~~
brunhilda.cpp:31:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int x; scanf("%d", &x);
          ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 78584 KB Output is correct
2 Correct 186 ms 78656 KB Output is correct
3 Correct 94 ms 78852 KB Output is correct
4 Correct 137 ms 78852 KB Output is correct
5 Correct 225 ms 78852 KB Output is correct
6 Correct 77 ms 78852 KB Output is correct
7 Correct 108 ms 78928 KB Output is correct
8 Correct 107 ms 78928 KB Output is correct
9 Correct 206 ms 78928 KB Output is correct
10 Correct 239 ms 78952 KB Output is correct
11 Correct 259 ms 78952 KB Output is correct
12 Correct 116 ms 78952 KB Output is correct
13 Correct 374 ms 78952 KB Output is correct
14 Correct 388 ms 78956 KB Output is correct
15 Correct 219 ms 79068 KB Output is correct
16 Correct 173 ms 79068 KB Output is correct
17 Correct 195 ms 79068 KB Output is correct
18 Correct 124 ms 79068 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 166 ms 79068 KB Output is correct
2 Correct 177 ms 79068 KB Output is correct
3 Correct 509 ms 79068 KB Output is correct
4 Correct 255 ms 79068 KB Output is correct
5 Correct 343 ms 79068 KB Output is correct
6 Correct 187 ms 79068 KB Output is correct
7 Correct 165 ms 79068 KB Output is correct
8 Correct 223 ms 79068 KB Output is correct
9 Correct 403 ms 79068 KB Output is correct
10 Correct 463 ms 79068 KB Output is correct
11 Correct 451 ms 79068 KB Output is correct
12 Correct 264 ms 79068 KB Output is correct
13 Correct 143 ms 79068 KB Output is correct
14 Correct 223 ms 79068 KB Output is correct
15 Correct 366 ms 79068 KB Output is correct
16 Correct 168 ms 79068 KB Output is correct
17 Correct 420 ms 79068 KB Output is correct
18 Correct 362 ms 79068 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 383 ms 79068 KB Output is correct
2 Correct 519 ms 79068 KB Output is correct
3 Correct 565 ms 79180 KB Output is correct
4 Correct 364 ms 79280 KB Output is correct
5 Correct 299 ms 79312 KB Output is correct
6 Correct 461 ms 79312 KB Output is correct
7 Correct 441 ms 79312 KB Output is correct
8 Correct 447 ms 79312 KB Output is correct
9 Correct 452 ms 79312 KB Output is correct
10 Correct 384 ms 79312 KB Output is correct
11 Correct 302 ms 79312 KB Output is correct
12 Correct 429 ms 79312 KB Output is correct
13 Correct 569 ms 79312 KB Output is correct
14 Correct 319 ms 79524 KB Output is correct
15 Correct 441 ms 79524 KB Output is correct
16 Correct 514 ms 79524 KB Output is correct
17 Correct 480 ms 79524 KB Output is correct
18 Correct 589 ms 79524 KB Output is correct
19 Correct 196 ms 79524 KB Output is correct
20 Correct 561 ms 79524 KB Output is correct
21 Correct 371 ms 79524 KB Output is correct
22 Correct 632 ms 79524 KB Output is correct
23 Correct 333 ms 79524 KB Output is correct
24 Correct 249 ms 79524 KB Output is correct
25 Correct 396 ms 79524 KB Output is correct
26 Correct 381 ms 79524 KB Output is correct
27 Correct 630 ms 79524 KB Output is correct
28 Correct 242 ms 79524 KB Output is correct
29 Correct 582 ms 79524 KB Output is correct
30 Correct 542 ms 79524 KB Output is correct
31 Correct 295 ms 79524 KB Output is correct
32 Correct 358 ms 79524 KB Output is correct
33 Correct 254 ms 79524 KB Output is correct
34 Correct 509 ms 79524 KB Output is correct
35 Correct 255 ms 79524 KB Output is correct
36 Correct 583 ms 79524 KB Output is correct
37 Correct 300 ms 79524 KB Output is correct
38 Correct 459 ms 79524 KB Output is correct
39 Correct 264 ms 79524 KB Output is correct
40 Correct 401 ms 79524 KB Output is correct
41 Correct 392 ms 79524 KB Output is correct
42 Correct 499 ms 79524 KB Output is correct