Submission #30898

# Submission time Handle Problem Language Result Execution time Memory
30898 2017-07-31T13:16:51 Z Navick Brunhilda’s Birthday (BOI13_brunhilda) C++14
20 / 100
116 ms 2096 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 = 1e4 + 10, INF = 1e9;

int dp[N], p[N];

int main(){
	int m, q; cin >> m >> q;
	
	if(m >= N || q>=N){
		cout << 1/0;
		return 0;
	}

	for(int i=0; i<m; i++)
		cin >> p[i];
	
	for(int i=1; i<N; i++){
		//dp[i] ?!
		int mr = 0;
		for(int j=0; j<m; j++)
			mr = max(mr, i % p[j]);
		if(mr == 0)dp[i] = INF;
		else dp[i] = dp[i - mr] + 1;
	}
	for(int i=0; i<q; i++){
		int n; cin >> n;
		if(dp[n] >= INF)
			cout << "oo\n";
		else cout << dp[n] << '\n';
	}
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:20:12: warning: division by zero [-Wdiv-by-zero]
   cout << 1/0;
            ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2096 KB Output is correct
2 Correct 3 ms 2096 KB Output is correct
3 Correct 0 ms 2096 KB Output is correct
4 Correct 16 ms 2096 KB Output is correct
5 Correct 0 ms 2096 KB Output is correct
6 Correct 0 ms 2096 KB Output is correct
7 Correct 0 ms 2096 KB Output is correct
8 Correct 0 ms 2096 KB Output is correct
9 Correct 0 ms 2096 KB Output is correct
10 Correct 3 ms 2096 KB Output is correct
11 Correct 0 ms 2096 KB Output is correct
12 Correct 3 ms 2096 KB Output is correct
13 Correct 36 ms 2096 KB Output is correct
14 Correct 56 ms 2096 KB Output is correct
15 Correct 0 ms 2096 KB Output is correct
16 Correct 6 ms 2096 KB Output is correct
17 Correct 16 ms 2096 KB Output is correct
18 Correct 9 ms 2096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
3 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
4 Runtime error 113 ms 2096 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
6 Runtime error 46 ms 2096 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
8 Runtime error 46 ms 2096 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
10 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
11 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
12 Runtime error 79 ms 2096 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 106 ms 2096 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 109 ms 2096 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
16 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
17 Runtime error 116 ms 2096 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
3 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
4 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
5 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
6 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
7 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
8 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
9 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
10 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
11 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
12 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
13 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
14 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
15 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
16 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
17 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
18 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
19 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
20 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
21 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
22 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
23 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
24 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
25 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
26 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
27 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
28 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
29 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
30 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
31 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
32 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
33 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
34 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
35 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
36 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
37 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
38 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
39 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
40 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
41 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)
42 Runtime error 0 ms 2096 KB Execution killed with signal 8 (could be triggered by violating memory limits)