Submission #134508

# Submission time Handle Problem Language Result Execution time Memory
134508 2019-07-23T00:28:48 Z degelo Brunhilda’s Birthday (BOI13_brunhilda) C++17
2.22222 / 100
1000 ms 2680 KB
#include<bits/stdc++.h>
#define inf 1000000000
#define maxn 100000
using namespace std;
long long int prod=1;
int m,q;
int p[100000];
int dp[100000];
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:32: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 1073 ms 376 KB Time limit exceeded
2 Execution timed out 1081 ms 364 KB Time limit exceeded
3 Execution timed out 1081 ms 376 KB Time limit exceeded
4 Execution timed out 1083 ms 376 KB Time limit exceeded
5 Execution timed out 1084 ms 376 KB Time limit exceeded
6 Execution timed out 1070 ms 376 KB Time limit exceeded
7 Execution timed out 1085 ms 376 KB Time limit exceeded
8 Execution timed out 1087 ms 400 KB Time limit exceeded
9 Execution timed out 1073 ms 376 KB Time limit exceeded
10 Execution timed out 1081 ms 400 KB Time limit exceeded
11 Execution timed out 1089 ms 504 KB Time limit exceeded
12 Correct 2 ms 376 KB Output is correct
13 Execution timed out 1090 ms 376 KB Time limit exceeded
14 Correct 4 ms 376 KB Output is correct
15 Execution timed out 1089 ms 376 KB Time limit exceeded
16 Execution timed out 1077 ms 376 KB Time limit exceeded
17 Execution timed out 1071 ms 376 KB Time limit exceeded
18 Execution timed out 1082 ms 376 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 376 KB Output isn't correct
2 Incorrect 15 ms 1400 KB Output isn't correct
3 Incorrect 11 ms 1016 KB Output isn't correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Incorrect 9 ms 888 KB Output isn't correct
6 Incorrect 2 ms 376 KB Output isn't correct
7 Incorrect 4 ms 504 KB Output isn't correct
8 Incorrect 2 ms 376 KB Output isn't correct
9 Incorrect 12 ms 1144 KB Output isn't correct
10 Incorrect 11 ms 1016 KB Output isn't correct
11 Incorrect 7 ms 760 KB Output isn't correct
12 Incorrect 2 ms 376 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 Incorrect 8 ms 820 KB Output isn't correct
16 Incorrect 15 ms 1400 KB Output isn't correct
17 Incorrect 2 ms 376 KB Output isn't correct
18 Incorrect 16 ms 1400 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 1320 KB Output isn't correct
2 Runtime error 10 ms 1272 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Incorrect 19 ms 1476 KB Output isn't correct
4 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Incorrect 37 ms 2680 KB Output isn't correct
6 Execution timed out 1083 ms 1144 KB Time limit exceeded
7 Incorrect 27 ms 2040 KB Output isn't correct
8 Incorrect 17 ms 1272 KB Output isn't correct
9 Incorrect 21 ms 1272 KB Output isn't correct
10 Execution timed out 1085 ms 1016 KB Time limit exceeded
11 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Execution timed out 1067 ms 1016 KB Time limit exceeded
13 Incorrect 23 ms 1784 KB Output isn't correct
14 Incorrect 19 ms 1400 KB Output isn't correct
15 Runtime error 3 ms 636 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 9 ms 1272 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 10 ms 1404 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Incorrect 19 ms 1528 KB Output isn't correct
21 Incorrect 20 ms 1400 KB Output isn't correct
22 Incorrect 36 ms 2556 KB Output isn't correct
23 Incorrect 27 ms 1656 KB Output isn't correct
24 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
27 Incorrect 25 ms 2040 KB Output isn't correct
28 Incorrect 20 ms 1400 KB Output isn't correct
29 Incorrect 36 ms 2552 KB Output isn't correct
30 Incorrect 32 ms 2168 KB Output isn't correct
31 Incorrect 21 ms 1272 KB Output isn't correct
32 Execution timed out 1083 ms 760 KB Time limit exceeded
33 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
34 Incorrect 27 ms 2040 KB Output isn't correct
35 Incorrect 20 ms 1372 KB Output isn't correct
36 Runtime error 17 ms 2040 KB Execution killed with signal 11 (could be triggered by violating memory limits)
37 Incorrect 36 ms 2552 KB Output isn't correct
38 Execution timed out 1083 ms 1144 KB Time limit exceeded
39 Execution timed out 1083 ms 376 KB Time limit exceeded
40 Runtime error 4 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
41 Incorrect 26 ms 2040 KB Output isn't correct
42 Incorrect 21 ms 1400 KB Output isn't correct