Submission #134510

# Submission time Handle Problem Language Result Execution time Memory
134510 2019-07-23T00:33:08 Z degelo Brunhilda’s Birthday (BOI13_brunhilda) C++17
2.22222 / 100
1000 ms 1144 KB
#include<bits/stdc++.h>
#define inf 1000000000
#define maxn 20000
using namespace std;
long long int prod=1;
int m,q;
int p[maxn];
int dp[maxn];
int DP(int k){
	if(dp[k]!=0) return dp[k];
	if(k==0) return 0;
	if(k<p[m-1]) return 1;
	int resp=inf;
	for(int i=0;i<m;i++){
		if(k%p[i]==0) continue;
		resp=min(resp,DP((k/p[i])*p[i])+1);
	}
	return resp;
}
int main(){
	scanf("%d %d",&m,&q); 
	for(int i=0;i<m;i++){
		scanf("%d",&p[i]);
	}
	for(int i=0;i<m;i++){
		prod*=p[i];
		if(prod>maxn) break;
	}
	for(int i=0;i<q;i++){
		int n;
		scanf("%d",&n);
		if(n>=prod) printf("oo\n");
		else printf("%d\n",DP(n));
	}
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:21: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:23:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&p[i]);
   ~~~~~^~~~~~~~~~~~
brunhilda.cpp:31:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&n);
   ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 376 KB Time limit exceeded
2 Execution timed out 1089 ms 376 KB Time limit exceeded
3 Execution timed out 1079 ms 376 KB Time limit exceeded
4 Execution timed out 1074 ms 256 KB Time limit exceeded
5 Execution timed out 1074 ms 256 KB Time limit exceeded
6 Execution timed out 1079 ms 376 KB Time limit exceeded
7 Execution timed out 1076 ms 376 KB Time limit exceeded
8 Execution timed out 1076 ms 376 KB Time limit exceeded
9 Execution timed out 1088 ms 376 KB Time limit exceeded
10 Execution timed out 1084 ms 504 KB Time limit exceeded
11 Execution timed out 1070 ms 504 KB Time limit exceeded
12 Correct 2 ms 256 KB Output is correct
13 Execution timed out 1067 ms 376 KB Time limit exceeded
14 Correct 4 ms 376 KB Output is correct
15 Execution timed out 1093 ms 376 KB Time limit exceeded
16 Execution timed out 1063 ms 376 KB Time limit exceeded
17 Execution timed out 1079 ms 256 KB Time limit exceeded
18 Execution timed out 1079 ms 376 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 376 KB Output isn't correct
2 Execution timed out 5 ms 376 KB Time limit exceeded (wall clock)
3 Execution timed out 5 ms 420 KB Time limit exceeded (wall clock)
4 Incorrect 2 ms 376 KB Output isn't correct
5 Execution timed out 5 ms 376 KB Time limit exceeded (wall clock)
6 Incorrect 2 ms 376 KB Output isn't correct
7 Incorrect 4 ms 376 KB Output isn't correct
8 Incorrect 2 ms 376 KB Output isn't correct
9 Execution timed out 6 ms 376 KB Time limit exceeded (wall clock)
10 Execution timed out 6 ms 376 KB Time limit exceeded (wall clock)
11 Execution timed out 5 ms 376 KB Time limit exceeded (wall clock)
12 Incorrect 3 ms 256 KB Output isn't correct
13 Incorrect 2 ms 376 KB Output isn't correct
14 Incorrect 2 ms 376 KB Output isn't correct
15 Execution timed out 5 ms 376 KB Time limit exceeded (wall clock)
16 Execution timed out 5 ms 376 KB Time limit exceeded (wall clock)
17 Incorrect 2 ms 376 KB Output isn't correct
18 Execution timed out 5 ms 376 KB Time limit exceeded (wall clock)
# Verdict Execution time Memory Grader output
1 Execution timed out 6 ms 376 KB Time limit exceeded (wall clock)
2 Execution timed out 5 ms 376 KB Time limit exceeded (wall clock)
3 Execution timed out 5 ms 376 KB Time limit exceeded (wall clock)
4 Incorrect 21 ms 1144 KB Output isn't correct
5 Execution timed out 5 ms 376 KB Time limit exceeded (wall clock)
6 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Execution timed out 5 ms 376 KB Time limit exceeded (wall clock)
8 Execution timed out 5 ms 376 KB Time limit exceeded (wall clock)
9 Execution timed out 5 ms 376 KB Time limit exceeded (wall clock)
10 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 4 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 4 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Execution timed out 5 ms 376 KB Time limit exceeded (wall clock)
14 Incorrect 19 ms 632 KB Output isn't correct
15 Incorrect 8 ms 504 KB Output isn't correct
16 Incorrect 7 ms 504 KB Output isn't correct
17 Execution timed out 5 ms 376 KB Time limit exceeded (wall clock)
18 Execution timed out 5 ms 376 KB Time limit exceeded (wall clock)
19 Runtime error 4 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Execution timed out 6 ms 376 KB Time limit exceeded (wall clock)
21 Incorrect 20 ms 632 KB Output isn't correct
22 Execution timed out 5 ms 376 KB Time limit exceeded (wall clock)
23 Execution timed out 5 ms 376 KB Time limit exceeded (wall clock)
24 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Incorrect 21 ms 1144 KB Output isn't correct
27 Execution timed out 5 ms 376 KB Time limit exceeded (wall clock)
28 Incorrect 20 ms 632 KB Output isn't correct
29 Execution timed out 6 ms 376 KB Time limit exceeded (wall clock)
30 Execution timed out 5 ms 376 KB Time limit exceeded (wall clock)
31 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Runtime error 3 ms 508 KB Execution killed with signal 11 (could be triggered by violating memory limits)
33 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
34 Execution timed out 5 ms 376 KB Time limit exceeded (wall clock)
35 Incorrect 20 ms 632 KB Output isn't correct
36 Execution timed out 5 ms 376 KB Time limit exceeded (wall clock)
37 Execution timed out 5 ms 380 KB Time limit exceeded (wall clock)
38 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
39 Runtime error 3 ms 508 KB Execution killed with signal 11 (could be triggered by violating memory limits)
40 Incorrect 23 ms 1144 KB Output isn't correct
41 Execution timed out 5 ms 376 KB Time limit exceeded (wall clock)
42 Incorrect 20 ms 632 KB Output isn't correct