답안 #30899

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
30899 2017-07-31T13:33:45 Z Navick Brunhilda’s Birthday (BOI13_brunhilda) C++14
20.6349 / 100
1000 ms 80144 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define pii pair<int, int>
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e7 + 10, INF = 1e9;

int dp[N], p[N];

int main(){
	int m, q; scanf("%d %d", &m, &q);
	
	for(int i=0; i<m; i++)
		scanf("%d", p + i);
	
	for(int i=1; i<N; i++){
		//dp[i] ?!
		int mr = 0;
		for(int j=m - 1; j>=0 && mr < p[j]; j--)
			mr = max(mr, i % p[j]);

		if(mr == 0){
			dp[i] = 0;
			break;
		}
		else dp[i] = dp[i - mr] + 1;
	}
	for(int i=0; i<q; i++){
		int n; scanf("%d", &n);
		if(dp[n] == 0)
			printf("oo\n");
		else printf("%d\n", dp[n]);
	}
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:17:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int m, q; scanf("%d %d", &m, &q);
                                  ^
brunhilda.cpp:20:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", p + i);
                     ^
brunhilda.cpp:35:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int n; scanf("%d", &n);
                         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 80144 KB Output is correct
2 Correct 403 ms 80144 KB Output is correct
3 Correct 3 ms 80144 KB Output is correct
4 Correct 416 ms 80144 KB Output is correct
5 Correct 236 ms 80144 KB Output is correct
6 Correct 0 ms 80144 KB Output is correct
7 Correct 3 ms 80144 KB Output is correct
8 Correct 9 ms 80144 KB Output is correct
9 Correct 179 ms 80144 KB Output is correct
10 Correct 153 ms 80144 KB Output is correct
11 Correct 196 ms 80144 KB Output is correct
12 Correct 856 ms 80144 KB Output is correct
13 Execution timed out 1000 ms 80144 KB Execution timed out
14 Execution timed out 1000 ms 80144 KB Execution timed out
15 Correct 306 ms 80144 KB Output is correct
16 Correct 406 ms 80144 KB Output is correct
17 Correct 339 ms 80144 KB Output is correct
18 Correct 419 ms 80144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1000 ms 80144 KB Execution timed out
2 Execution timed out 1000 ms 80144 KB Execution timed out
3 Execution timed out 1000 ms 80144 KB Execution timed out
4 Execution timed out 1000 ms 80144 KB Execution timed out
5 Execution timed out 1000 ms 80144 KB Execution timed out
6 Execution timed out 1000 ms 80144 KB Execution timed out
7 Execution timed out 1000 ms 80144 KB Execution timed out
8 Execution timed out 1000 ms 80144 KB Execution timed out
9 Execution timed out 1000 ms 80144 KB Execution timed out
10 Execution timed out 1000 ms 80144 KB Execution timed out
11 Execution timed out 1000 ms 80144 KB Execution timed out
12 Execution timed out 1000 ms 80144 KB Execution timed out
13 Execution timed out 1000 ms 80144 KB Execution timed out
14 Execution timed out 1000 ms 80144 KB Execution timed out
15 Execution timed out 1000 ms 80144 KB Execution timed out
16 Execution timed out 1000 ms 80144 KB Execution timed out
17 Execution timed out 1000 ms 80144 KB Execution timed out
18 Execution timed out 1000 ms 80144 KB Execution timed out
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1000 ms 80144 KB Execution timed out
2 Execution timed out 1000 ms 80144 KB Execution timed out
3 Execution timed out 1000 ms 80144 KB Execution timed out
4 Execution timed out 1000 ms 80144 KB Execution timed out
5 Execution timed out 1000 ms 80144 KB Execution timed out
6 Execution timed out 1000 ms 80144 KB Execution timed out
7 Execution timed out 1000 ms 80144 KB Execution timed out
8 Execution timed out 1000 ms 80144 KB Execution timed out
9 Execution timed out 1000 ms 80144 KB Execution timed out
10 Execution timed out 1000 ms 80144 KB Execution timed out
11 Execution timed out 1000 ms 80144 KB Execution timed out
12 Execution timed out 1000 ms 80144 KB Execution timed out
13 Execution timed out 1000 ms 80144 KB Execution timed out
14 Correct 319 ms 80144 KB Output is correct
15 Execution timed out 1000 ms 80144 KB Execution timed out
16 Execution timed out 1000 ms 80144 KB Execution timed out
17 Execution timed out 1000 ms 80144 KB Execution timed out
18 Execution timed out 1000 ms 80144 KB Execution timed out
19 Execution timed out 1000 ms 80144 KB Execution timed out
20 Execution timed out 1000 ms 80144 KB Execution timed out
21 Correct 303 ms 80144 KB Output is correct
22 Execution timed out 1000 ms 80144 KB Execution timed out
23 Execution timed out 1000 ms 80144 KB Execution timed out
24 Execution timed out 1000 ms 80144 KB Execution timed out
25 Execution timed out 1000 ms 80144 KB Execution timed out
26 Execution timed out 1000 ms 80144 KB Execution timed out
27 Execution timed out 1000 ms 80144 KB Execution timed out
28 Execution timed out 1000 ms 80144 KB Execution timed out
29 Execution timed out 1000 ms 80144 KB Execution timed out
30 Execution timed out 1000 ms 80144 KB Execution timed out
31 Execution timed out 1000 ms 80144 KB Execution timed out
32 Execution timed out 1000 ms 80144 KB Execution timed out
33 Execution timed out 1000 ms 80144 KB Execution timed out
34 Execution timed out 1000 ms 80144 KB Execution timed out
35 Execution timed out 1000 ms 80144 KB Execution timed out
36 Execution timed out 1000 ms 80144 KB Execution timed out
37 Execution timed out 1000 ms 80144 KB Execution timed out
38 Execution timed out 1000 ms 80144 KB Execution timed out
39 Execution timed out 1000 ms 80144 KB Execution timed out
40 Execution timed out 1000 ms 80144 KB Execution timed out
41 Execution timed out 1000 ms 80144 KB Execution timed out
42 Execution timed out 1000 ms 80144 KB Execution timed out