답안 #239422

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
239422 2020-06-15T14:32:02 Z luciocf Brunhilda’s Birthday (BOI13_brunhilda) C++14
100 / 100
368 ms 79352 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 1e5+10;
const int maxv = 1e7+10;

int p[maxn];

int prox[maxv], dp[maxv];

int main(void)
{
	int n, q;
	scanf("%d %d", &n, &q);

	int prod = 1;

	for (int i = 0; i < maxv; i++)
		prox[i] = 2*maxv;

	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &p[i]);
			
		if (prod != maxv)
		{
			if (1ll*prod*p[i] > 1ll*maxv)
				prod = maxv;
			else
				prod *= p[i];
		}

		for (int j = 0; j < maxv; j += p[i])
		{
			int a = min(maxv-1, j+p[i]-1);

			prox[a] = min(prox[a], j);
		}
	}


	for (int i = maxv-2; i >= 0; i--)
		prox[i] = min(prox[i], prox[i+1]);

	for (int i = 1; i < maxv; i++)
		dp[i] = dp[prox[i]] + 1;

	while (q--)
	{
		int x;
		scanf("%d", &x);

		if (prod <= x)
		{
			printf("oo\n");
			continue;
		}

		printf("%d\n", dp[x]);
	}
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &q);
  ~~~~~^~~~~~~~~~~~~~~~~
brunhilda.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &p[i]);
   ~~~~~^~~~~~~~~~~~~
brunhilda.cpp:52:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &x);
   ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 103 ms 78584 KB Output is correct
2 Correct 127 ms 78584 KB Output is correct
3 Correct 114 ms 78584 KB Output is correct
4 Correct 110 ms 78712 KB Output is correct
5 Correct 114 ms 78584 KB Output is correct
6 Correct 102 ms 78584 KB Output is correct
7 Correct 112 ms 78584 KB Output is correct
8 Correct 119 ms 78652 KB Output is correct
9 Correct 133 ms 78712 KB Output is correct
10 Correct 155 ms 78692 KB Output is correct
11 Correct 143 ms 78584 KB Output is correct
12 Correct 98 ms 78584 KB Output is correct
13 Correct 246 ms 78584 KB Output is correct
14 Correct 261 ms 78584 KB Output is correct
15 Correct 139 ms 78584 KB Output is correct
16 Correct 126 ms 78560 KB Output is correct
17 Correct 128 ms 78712 KB Output is correct
18 Correct 101 ms 78584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 116 ms 78588 KB Output is correct
2 Correct 143 ms 78968 KB Output is correct
3 Correct 319 ms 78864 KB Output is correct
4 Correct 140 ms 78584 KB Output is correct
5 Correct 227 ms 78840 KB Output is correct
6 Correct 144 ms 78560 KB Output is correct
7 Correct 118 ms 78584 KB Output is correct
8 Correct 137 ms 78584 KB Output is correct
9 Correct 273 ms 78968 KB Output is correct
10 Correct 309 ms 78840 KB Output is correct
11 Correct 356 ms 78712 KB Output is correct
12 Correct 209 ms 78584 KB Output is correct
13 Correct 108 ms 78584 KB Output is correct
14 Correct 140 ms 78712 KB Output is correct
15 Correct 257 ms 78840 KB Output is correct
16 Correct 138 ms 78968 KB Output is correct
17 Correct 262 ms 78584 KB Output is correct
18 Correct 261 ms 79096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 336 ms 78968 KB Output is correct
2 Correct 353 ms 78944 KB Output is correct
3 Correct 353 ms 79096 KB Output is correct
4 Correct 212 ms 78844 KB Output is correct
5 Correct 178 ms 79224 KB Output is correct
6 Correct 272 ms 78968 KB Output is correct
7 Correct 254 ms 79100 KB Output is correct
8 Correct 269 ms 78892 KB Output is correct
9 Correct 267 ms 78840 KB Output is correct
10 Correct 212 ms 78584 KB Output is correct
11 Correct 181 ms 78712 KB Output is correct
12 Correct 238 ms 78712 KB Output is correct
13 Correct 368 ms 78968 KB Output is correct
14 Correct 186 ms 79224 KB Output is correct
15 Correct 249 ms 78712 KB Output is correct
16 Correct 280 ms 78712 KB Output is correct
17 Correct 317 ms 78840 KB Output is correct
18 Correct 312 ms 78840 KB Output is correct
19 Correct 124 ms 78712 KB Output is correct
20 Correct 323 ms 78968 KB Output is correct
21 Correct 218 ms 79224 KB Output is correct
22 Correct 351 ms 79224 KB Output is correct
23 Correct 173 ms 78968 KB Output is correct
24 Correct 147 ms 78968 KB Output is correct
25 Correct 235 ms 78968 KB Output is correct
26 Correct 215 ms 78840 KB Output is correct
27 Correct 345 ms 79096 KB Output is correct
28 Correct 144 ms 78944 KB Output is correct
29 Correct 347 ms 79328 KB Output is correct
30 Correct 305 ms 79096 KB Output is correct
31 Correct 171 ms 78840 KB Output is correct
32 Correct 180 ms 78840 KB Output is correct
33 Correct 136 ms 78844 KB Output is correct
34 Correct 247 ms 79096 KB Output is correct
35 Correct 149 ms 78968 KB Output is correct
36 Correct 367 ms 79212 KB Output is correct
37 Correct 172 ms 79352 KB Output is correct
38 Correct 276 ms 78968 KB Output is correct
39 Correct 160 ms 78980 KB Output is correct
40 Correct 245 ms 78840 KB Output is correct
41 Correct 231 ms 79096 KB Output is correct
42 Correct 331 ms 79188 KB Output is correct