답안 #66184

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
66184 2018-08-10T02:04:43 Z MatheusLealV Brunhilda’s Birthday (BOI13_brunhilda) C++17
21.4286 / 100
83 ms 36672 KB
#include <bits/stdc++.h>
#define N 100050
using namespace std;

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

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

	cin>>n>>q;

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

		for(int j = p[i]; j < N; j+= p[i]) pr[j] = p[i];
	}

	pr[0] = p[n];

	dp[0] = 1;

	for(int i = 0; i < 10000005; i++)
	{
		if(!dp[i]) continue;

		for(int j = lim + 1; j < min(10000005, i + pr[i]); j++) dp[j] = dp[i] + 1;

		lim = max(lim, min(10000005, i + pr[i]) - 1);
	}

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

		if(!dp[x]) cout<<"oo\n";

		else cout<<dp[x] - 1<<"\n";
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 888 KB Output is correct
2 Correct 22 ms 1384 KB Output is correct
3 Correct 23 ms 1384 KB Output is correct
4 Correct 24 ms 1384 KB Output is correct
5 Correct 20 ms 1384 KB Output is correct
6 Correct 22 ms 1384 KB Output is correct
7 Correct 21 ms 1384 KB Output is correct
8 Correct 23 ms 1392 KB Output is correct
9 Correct 23 ms 1392 KB Output is correct
10 Correct 22 ms 1392 KB Output is correct
11 Correct 23 ms 1424 KB Output is correct
12 Correct 21 ms 1424 KB Output is correct
13 Correct 23 ms 1472 KB Output is correct
14 Correct 33 ms 1576 KB Output is correct
15 Correct 22 ms 1576 KB Output is correct
16 Correct 23 ms 1576 KB Output is correct
17 Correct 23 ms 1576 KB Output is correct
18 Correct 22 ms 1576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 25 ms 4620 KB Output isn't correct
2 Incorrect 70 ms 36672 KB Output isn't correct
3 Incorrect 38 ms 36672 KB Output isn't correct
4 Incorrect 23 ms 36672 KB Output isn't correct
5 Incorrect 34 ms 36672 KB Output isn't correct
6 Incorrect 23 ms 36672 KB Output isn't correct
7 Incorrect 27 ms 36672 KB Output isn't correct
8 Incorrect 20 ms 36672 KB Output isn't correct
9 Incorrect 36 ms 36672 KB Output isn't correct
10 Incorrect 41 ms 36672 KB Output isn't correct
11 Incorrect 30 ms 36672 KB Output isn't correct
12 Incorrect 21 ms 36672 KB Output isn't correct
13 Incorrect 23 ms 36672 KB Output isn't correct
14 Incorrect 22 ms 36672 KB Output isn't correct
15 Incorrect 28 ms 36672 KB Output isn't correct
16 Incorrect 79 ms 36672 KB Output isn't correct
17 Incorrect 21 ms 36672 KB Output isn't correct
18 Incorrect 53 ms 36672 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 38 ms 36672 KB Output isn't correct
2 Incorrect 32 ms 36672 KB Output isn't correct
3 Incorrect 43 ms 36672 KB Output isn't correct
4 Incorrect 38 ms 36672 KB Output isn't correct
5 Incorrect 70 ms 36672 KB Output isn't correct
6 Incorrect 37 ms 36672 KB Output isn't correct
7 Incorrect 53 ms 36672 KB Output isn't correct
8 Incorrect 38 ms 36672 KB Output isn't correct
9 Incorrect 37 ms 36672 KB Output isn't correct
10 Incorrect 23 ms 36672 KB Output isn't correct
11 Incorrect 26 ms 36672 KB Output isn't correct
12 Incorrect 30 ms 36672 KB Output isn't correct
13 Incorrect 44 ms 36672 KB Output isn't correct
14 Incorrect 37 ms 36672 KB Output isn't correct
15 Incorrect 33 ms 36672 KB Output isn't correct
16 Incorrect 27 ms 36672 KB Output isn't correct
17 Incorrect 34 ms 36672 KB Output isn't correct
18 Incorrect 37 ms 36672 KB Output isn't correct
19 Incorrect 28 ms 36672 KB Output isn't correct
20 Incorrect 40 ms 36672 KB Output isn't correct
21 Incorrect 37 ms 36672 KB Output isn't correct
22 Incorrect 56 ms 36672 KB Output isn't correct
23 Incorrect 47 ms 36672 KB Output isn't correct
24 Incorrect 40 ms 36672 KB Output isn't correct
25 Incorrect 40 ms 36672 KB Output isn't correct
26 Incorrect 38 ms 36672 KB Output isn't correct
27 Incorrect 50 ms 36672 KB Output isn't correct
28 Incorrect 41 ms 36672 KB Output isn't correct
29 Incorrect 52 ms 36672 KB Output isn't correct
30 Incorrect 48 ms 36672 KB Output isn't correct
31 Incorrect 37 ms 36672 KB Output isn't correct
32 Incorrect 35 ms 36672 KB Output isn't correct
33 Incorrect 34 ms 36672 KB Output isn't correct
34 Incorrect 55 ms 36672 KB Output isn't correct
35 Incorrect 38 ms 36672 KB Output isn't correct
36 Incorrect 60 ms 36672 KB Output isn't correct
37 Incorrect 75 ms 36672 KB Output isn't correct
38 Incorrect 36 ms 36672 KB Output isn't correct
39 Incorrect 36 ms 36672 KB Output isn't correct
40 Incorrect 39 ms 36672 KB Output isn't correct
41 Correct 83 ms 36672 KB Output is correct
42 Incorrect 39 ms 36672 KB Output isn't correct