답안 #66187

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
66187 2018-08-10T02:06:43 Z MatheusLealV Brunhilda’s Birthday (BOI13_brunhilda) C++17
100 / 100
453 ms 79788 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 < 10000005; 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 67 ms 39672 KB Output is correct
2 Correct 144 ms 78820 KB Output is correct
3 Correct 76 ms 78820 KB Output is correct
4 Correct 96 ms 78820 KB Output is correct
5 Correct 139 ms 78820 KB Output is correct
6 Correct 64 ms 78820 KB Output is correct
7 Correct 76 ms 78820 KB Output is correct
8 Correct 80 ms 78820 KB Output is correct
9 Correct 207 ms 78824 KB Output is correct
10 Correct 194 ms 78824 KB Output is correct
11 Correct 201 ms 78824 KB Output is correct
12 Correct 96 ms 78896 KB Output is correct
13 Correct 314 ms 78896 KB Output is correct
14 Correct 326 ms 78896 KB Output is correct
15 Correct 147 ms 78984 KB Output is correct
16 Correct 141 ms 78984 KB Output is correct
17 Correct 134 ms 78988 KB Output is correct
18 Correct 111 ms 78988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 138 ms 79004 KB Output is correct
2 Correct 155 ms 79244 KB Output is correct
3 Correct 371 ms 79244 KB Output is correct
4 Correct 146 ms 79244 KB Output is correct
5 Correct 271 ms 79244 KB Output is correct
6 Correct 132 ms 79244 KB Output is correct
7 Correct 121 ms 79244 KB Output is correct
8 Correct 152 ms 79244 KB Output is correct
9 Correct 323 ms 79244 KB Output is correct
10 Correct 415 ms 79244 KB Output is correct
11 Correct 356 ms 79244 KB Output is correct
12 Correct 221 ms 79244 KB Output is correct
13 Correct 110 ms 79244 KB Output is correct
14 Correct 150 ms 79244 KB Output is correct
15 Correct 302 ms 79244 KB Output is correct
16 Correct 159 ms 79328 KB Output is correct
17 Correct 314 ms 79328 KB Output is correct
18 Correct 339 ms 79376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 329 ms 79508 KB Output is correct
2 Correct 419 ms 79508 KB Output is correct
3 Correct 426 ms 79508 KB Output is correct
4 Correct 265 ms 79508 KB Output is correct
5 Correct 196 ms 79700 KB Output is correct
6 Correct 343 ms 79700 KB Output is correct
7 Correct 315 ms 79700 KB Output is correct
8 Correct 330 ms 79700 KB Output is correct
9 Correct 326 ms 79700 KB Output is correct
10 Correct 249 ms 79700 KB Output is correct
11 Correct 220 ms 79700 KB Output is correct
12 Correct 327 ms 79700 KB Output is correct
13 Correct 392 ms 79700 KB Output is correct
14 Correct 224 ms 79700 KB Output is correct
15 Correct 331 ms 79700 KB Output is correct
16 Correct 356 ms 79700 KB Output is correct
17 Correct 310 ms 79700 KB Output is correct
18 Correct 423 ms 79700 KB Output is correct
19 Correct 132 ms 79700 KB Output is correct
20 Correct 388 ms 79700 KB Output is correct
21 Correct 243 ms 79700 KB Output is correct
22 Correct 412 ms 79700 KB Output is correct
23 Correct 198 ms 79700 KB Output is correct
24 Correct 164 ms 79700 KB Output is correct
25 Correct 285 ms 79700 KB Output is correct
26 Correct 245 ms 79700 KB Output is correct
27 Correct 453 ms 79700 KB Output is correct
28 Correct 151 ms 79700 KB Output is correct
29 Correct 421 ms 79788 KB Output is correct
30 Correct 362 ms 79788 KB Output is correct
31 Correct 177 ms 79788 KB Output is correct
32 Correct 203 ms 79788 KB Output is correct
33 Correct 128 ms 79788 KB Output is correct
34 Correct 285 ms 79788 KB Output is correct
35 Correct 177 ms 79788 KB Output is correct
36 Correct 434 ms 79788 KB Output is correct
37 Correct 189 ms 79788 KB Output is correct
38 Correct 318 ms 79788 KB Output is correct
39 Correct 153 ms 79788 KB Output is correct
40 Correct 262 ms 79788 KB Output is correct
41 Correct 267 ms 79788 KB Output is correct
42 Correct 382 ms 79788 KB Output is correct