Submission #66178

# Submission time Handle Problem Language Result Execution time Memory
66178 2018-08-10T01:15:18 Z MatheusLealV Brunhilda’s Birthday (BOI13_brunhilda) C++17
75.5556 / 100
148 ms 41148 KB
#include <bits/stdc++.h>
#define N 100050
using namespace std;

int n, q, p[N], dp[10000005], prox[10000005];

int solve(int x)
{
	if(!x) return 0;

	if(dp[x] != -1) return dp[x];

	int ans = -2000000000, opt = 0;

	for(int i = n; i >= max(1, n - 100); i--)
	{
		if(x % p[i] == 0) continue;

		if(x % p[i] > ans)
		{
			ans = x % p[i];

			opt = i;
		}
	}

	return dp[x] = opt ? solve(x - ans) + 1: 2000000000;
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);

	cin>>n>>q;

	for(int i = 1; i <= n; i++) cin>>p[i];

	sort(p + 1, p + n + 1);

	memset(dp, -1, sizeof dp);

	for(int i = 1, x; i <= q; i++)
	{
		cin>>x;

		int s = solve(x);

		if(s >= 2000000000) cout<<"oo\n";

		else cout<<s<<"\n";

		//print(x);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 30 ms 39416 KB Output is correct
2 Correct 30 ms 39652 KB Output is correct
3 Correct 30 ms 39652 KB Output is correct
4 Correct 38 ms 39696 KB Output is correct
5 Correct 30 ms 39832 KB Output is correct
6 Correct 35 ms 39832 KB Output is correct
7 Correct 32 ms 39832 KB Output is correct
8 Correct 30 ms 39832 KB Output is correct
9 Correct 30 ms 39832 KB Output is correct
10 Correct 31 ms 39832 KB Output is correct
11 Correct 30 ms 39832 KB Output is correct
12 Correct 35 ms 39832 KB Output is correct
13 Correct 36 ms 39832 KB Output is correct
14 Correct 37 ms 39832 KB Output is correct
15 Correct 35 ms 39832 KB Output is correct
16 Correct 36 ms 39932 KB Output is correct
17 Correct 36 ms 39932 KB Output is correct
18 Correct 44 ms 39932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 39932 KB Output is correct
2 Correct 43 ms 40184 KB Output is correct
3 Correct 40 ms 40184 KB Output is correct
4 Incorrect 32 ms 40184 KB Output isn't correct
5 Correct 37 ms 40184 KB Output is correct
6 Correct 35 ms 40184 KB Output is correct
7 Correct 34 ms 40184 KB Output is correct
8 Correct 35 ms 40184 KB Output is correct
9 Correct 41 ms 40184 KB Output is correct
10 Correct 48 ms 40184 KB Output is correct
11 Incorrect 35 ms 40184 KB Output isn't correct
12 Correct 30 ms 40184 KB Output is correct
13 Correct 35 ms 40184 KB Output is correct
14 Incorrect 38 ms 40184 KB Output isn't correct
15 Correct 39 ms 40184 KB Output is correct
16 Correct 48 ms 40184 KB Output is correct
17 Correct 35 ms 40184 KB Output is correct
18 Incorrect 46 ms 40184 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 79 ms 40184 KB Output is correct
2 Correct 66 ms 40184 KB Output is correct
3 Correct 75 ms 40184 KB Output is correct
4 Incorrect 111 ms 40184 KB Output isn't correct
5 Correct 125 ms 40492 KB Output is correct
6 Incorrect 111 ms 40492 KB Output isn't correct
7 Correct 86 ms 40492 KB Output is correct
8 Correct 76 ms 40492 KB Output is correct
9 Correct 78 ms 40492 KB Output is correct
10 Incorrect 45 ms 40492 KB Output isn't correct
11 Incorrect 67 ms 40492 KB Output isn't correct
12 Incorrect 60 ms 40492 KB Output isn't correct
13 Incorrect 94 ms 40492 KB Output isn't correct
14 Correct 81 ms 41148 KB Output is correct
15 Incorrect 65 ms 41148 KB Output isn't correct
16 Incorrect 59 ms 41148 KB Output isn't correct
17 Correct 52 ms 41148 KB Output is correct
18 Correct 62 ms 41148 KB Output is correct
19 Correct 54 ms 41148 KB Output is correct
20 Correct 83 ms 41148 KB Output is correct
21 Correct 113 ms 41148 KB Output is correct
22 Correct 148 ms 41148 KB Output is correct
23 Correct 123 ms 41148 KB Output is correct
24 Correct 124 ms 41148 KB Output is correct
25 Incorrect 130 ms 41148 KB Output isn't correct
26 Incorrect 116 ms 41148 KB Output isn't correct
27 Correct 87 ms 41148 KB Output is correct
28 Correct 102 ms 41148 KB Output is correct
29 Correct 135 ms 41148 KB Output is correct
30 Correct 119 ms 41148 KB Output is correct
31 Correct 112 ms 41148 KB Output is correct
32 Correct 120 ms 41148 KB Output is correct
33 Incorrect 99 ms 41148 KB Output isn't correct
34 Correct 76 ms 41148 KB Output is correct
35 Correct 102 ms 41148 KB Output is correct
36 Correct 121 ms 41148 KB Output is correct
37 Correct 124 ms 41148 KB Output is correct
38 Incorrect 119 ms 41148 KB Output isn't correct
39 Incorrect 121 ms 41148 KB Output isn't correct
40 Correct 122 ms 41148 KB Output is correct
41 Correct 89 ms 41148 KB Output is correct
42 Incorrect 103 ms 41148 KB Output isn't correct