답안 #23427

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
23427 2017-05-09T07:13:04 Z 14kg Bali Sculptures (APIO15_sculpture) C++11
100 / 100
283 ms 36356 KB
#include <stdio.h>
#define N 2002
#define INF 999999999
#define min2(x,y) (x<y?x:y)
#define max2(x,y) (x>y?x:y)

int n, L, R, nn;
bool out[51], check[N][N];
long long p[51], in[N], s[N][N];

int main()
{
	int num, temp1[N], temp2[N];
	long long sum, tot=0;

	scanf("%d %d %d", &n, &L, &R);
	for (int i = 1; i <= n; i++) scanf("%lld", &in[i]);
	p[0] = 1;
	for (int i = 1; i <= 50; i++) p[i] = p[i - 1] * 2;
	for (int i = 1; i <= n; i++) for (int j = i; j <= n; j++) s[i][j] = s[i][j - 1] + in[j];
	if (s[1][n] == 0) { printf("0"); return 0; }

	for (int i = 49; i >= 0; i--)
	{
		num = 1, sum = 0;
		for (int j = 1; j <= n; j++)
		{
			sum += in[j];
			if (sum >= p[i + 1]) sum = in[j], num++;
			if (sum >= p[i + 1]) { num = INF; break; }
		}
		if (num > R) { nn = i + 1; break; }
	} out[nn] = true;

	for (int i = 1; i <= n; i++)
		for (int j = i; j <= n; j++) if (s[i][j] < p[nn + 1]) check[i][j] = true;

	for (int i = nn - 1; i >= 0; i--)
	{
		temp1[1] = 0, temp2[1] = 0;
		for (int j = 2; j <= n + 1; j++) temp1[j] = INF, temp2[j] = -INF;
		
		for (int j = 1; j <= n; j++)
			for (int t = j; t <= n; t++) if (check[j][t] && (s[j][t] & p[i]) == 0)
				temp1[t + 1] = min2(temp1[t + 1], temp1[j] + 1), temp2[t + 1] = max2(temp2[t + 1], temp2[j] + 1);

		if (temp1[n + 1] != INF && L <= temp2[n + 1] && temp1[n + 1] <= R)
		{
			for (int j = 1; j <= n; j++)
				for (int t = j; t <= n; t++) if (s[j][t] & p[i]) check[j][t] = false;
		}
		else out[i] = true;
	}
	for (int i = nn; i >= 0; i--)
		if (out[i]) tot += p[i];
	printf("%lld", tot);
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:16:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &n, &L, &R);
                               ^
sculpture.cpp:17:52: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i = 1; i <= n; i++) scanf("%lld", &in[i]);
                                                    ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 36356 KB Output is correct
2 Correct 0 ms 36356 KB Output is correct
3 Correct 0 ms 36356 KB Output is correct
4 Correct 0 ms 36356 KB Output is correct
5 Correct 0 ms 36356 KB Output is correct
6 Correct 0 ms 36356 KB Output is correct
7 Correct 0 ms 36356 KB Output is correct
8 Correct 0 ms 36356 KB Output is correct
9 Correct 0 ms 36356 KB Output is correct
10 Correct 0 ms 36356 KB Output is correct
11 Correct 0 ms 36356 KB Output is correct
12 Correct 0 ms 36356 KB Output is correct
13 Correct 0 ms 36356 KB Output is correct
14 Correct 0 ms 36356 KB Output is correct
15 Correct 0 ms 36356 KB Output is correct
16 Correct 0 ms 36356 KB Output is correct
17 Correct 0 ms 36356 KB Output is correct
18 Correct 0 ms 36356 KB Output is correct
19 Correct 0 ms 36356 KB Output is correct
20 Correct 0 ms 36356 KB Output is correct
21 Correct 0 ms 36356 KB Output is correct
22 Correct 0 ms 36356 KB Output is correct
23 Correct 0 ms 36356 KB Output is correct
24 Correct 0 ms 36356 KB Output is correct
25 Correct 0 ms 36356 KB Output is correct
26 Correct 0 ms 36356 KB Output is correct
27 Correct 0 ms 36356 KB Output is correct
28 Correct 0 ms 36356 KB Output is correct
29 Correct 0 ms 36356 KB Output is correct
30 Correct 0 ms 36356 KB Output is correct
31 Correct 0 ms 36356 KB Output is correct
32 Correct 0 ms 36356 KB Output is correct
33 Correct 0 ms 36356 KB Output is correct
34 Correct 0 ms 36356 KB Output is correct
35 Correct 0 ms 36356 KB Output is correct
36 Correct 0 ms 36356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 36356 KB Output is correct
2 Correct 0 ms 36356 KB Output is correct
3 Correct 0 ms 36356 KB Output is correct
4 Correct 0 ms 36356 KB Output is correct
5 Correct 0 ms 36356 KB Output is correct
6 Correct 0 ms 36356 KB Output is correct
7 Correct 0 ms 36356 KB Output is correct
8 Correct 0 ms 36356 KB Output is correct
9 Correct 0 ms 36356 KB Output is correct
10 Correct 0 ms 36356 KB Output is correct
11 Correct 0 ms 36356 KB Output is correct
12 Correct 0 ms 36356 KB Output is correct
13 Correct 0 ms 36356 KB Output is correct
14 Correct 0 ms 36356 KB Output is correct
15 Correct 0 ms 36356 KB Output is correct
16 Correct 0 ms 36356 KB Output is correct
17 Correct 0 ms 36356 KB Output is correct
18 Correct 0 ms 36356 KB Output is correct
19 Correct 0 ms 36356 KB Output is correct
20 Correct 0 ms 36356 KB Output is correct
21 Correct 0 ms 36356 KB Output is correct
22 Correct 0 ms 36356 KB Output is correct
23 Correct 0 ms 36356 KB Output is correct
24 Correct 0 ms 36356 KB Output is correct
25 Correct 0 ms 36356 KB Output is correct
26 Correct 0 ms 36356 KB Output is correct
27 Correct 0 ms 36356 KB Output is correct
28 Correct 0 ms 36356 KB Output is correct
29 Correct 0 ms 36356 KB Output is correct
30 Correct 0 ms 36356 KB Output is correct
31 Correct 0 ms 36356 KB Output is correct
32 Correct 0 ms 36356 KB Output is correct
33 Correct 0 ms 36356 KB Output is correct
34 Correct 0 ms 36356 KB Output is correct
35 Correct 0 ms 36356 KB Output is correct
36 Correct 0 ms 36356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 36356 KB Output is correct
2 Correct 0 ms 36356 KB Output is correct
3 Correct 0 ms 36356 KB Output is correct
4 Correct 0 ms 36356 KB Output is correct
5 Correct 0 ms 36356 KB Output is correct
6 Correct 0 ms 36356 KB Output is correct
7 Correct 0 ms 36356 KB Output is correct
8 Correct 0 ms 36356 KB Output is correct
9 Correct 0 ms 36356 KB Output is correct
10 Correct 0 ms 36356 KB Output is correct
11 Correct 0 ms 36356 KB Output is correct
12 Correct 0 ms 36356 KB Output is correct
13 Correct 0 ms 36356 KB Output is correct
14 Correct 0 ms 36356 KB Output is correct
15 Correct 0 ms 36356 KB Output is correct
16 Correct 0 ms 36356 KB Output is correct
17 Correct 0 ms 36356 KB Output is correct
18 Correct 0 ms 36356 KB Output is correct
19 Correct 0 ms 36356 KB Output is correct
20 Correct 0 ms 36356 KB Output is correct
21 Correct 0 ms 36356 KB Output is correct
22 Correct 0 ms 36356 KB Output is correct
23 Correct 0 ms 36356 KB Output is correct
24 Correct 0 ms 36356 KB Output is correct
25 Correct 0 ms 36356 KB Output is correct
26 Correct 0 ms 36356 KB Output is correct
27 Correct 0 ms 36356 KB Output is correct
28 Correct 0 ms 36356 KB Output is correct
29 Correct 0 ms 36356 KB Output is correct
30 Correct 0 ms 36356 KB Output is correct
31 Correct 0 ms 36356 KB Output is correct
32 Correct 0 ms 36356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 36356 KB Output is correct
2 Correct 0 ms 36356 KB Output is correct
3 Correct 0 ms 36356 KB Output is correct
4 Correct 0 ms 36356 KB Output is correct
5 Correct 0 ms 36356 KB Output is correct
6 Correct 0 ms 36356 KB Output is correct
7 Correct 0 ms 36356 KB Output is correct
8 Correct 0 ms 36356 KB Output is correct
9 Correct 0 ms 36356 KB Output is correct
10 Correct 0 ms 36356 KB Output is correct
11 Correct 0 ms 36356 KB Output is correct
12 Correct 0 ms 36356 KB Output is correct
13 Correct 0 ms 36356 KB Output is correct
14 Correct 0 ms 36356 KB Output is correct
15 Correct 0 ms 36356 KB Output is correct
16 Correct 0 ms 36356 KB Output is correct
17 Correct 0 ms 36356 KB Output is correct
18 Correct 0 ms 36356 KB Output is correct
19 Correct 0 ms 36356 KB Output is correct
20 Correct 0 ms 36356 KB Output is correct
21 Correct 0 ms 36356 KB Output is correct
22 Correct 0 ms 36356 KB Output is correct
23 Correct 0 ms 36356 KB Output is correct
24 Correct 0 ms 36356 KB Output is correct
25 Correct 0 ms 36356 KB Output is correct
26 Correct 0 ms 36356 KB Output is correct
27 Correct 0 ms 36356 KB Output is correct
28 Correct 0 ms 36356 KB Output is correct
29 Correct 0 ms 36356 KB Output is correct
30 Correct 0 ms 36356 KB Output is correct
31 Correct 0 ms 36356 KB Output is correct
32 Correct 0 ms 36356 KB Output is correct
33 Correct 0 ms 36356 KB Output is correct
34 Correct 0 ms 36356 KB Output is correct
35 Correct 0 ms 36356 KB Output is correct
36 Correct 0 ms 36356 KB Output is correct
37 Correct 0 ms 36356 KB Output is correct
38 Correct 0 ms 36356 KB Output is correct
39 Correct 0 ms 36356 KB Output is correct
40 Correct 0 ms 36356 KB Output is correct
41 Correct 0 ms 36356 KB Output is correct
42 Correct 0 ms 36356 KB Output is correct
43 Correct 0 ms 36356 KB Output is correct
44 Correct 0 ms 36356 KB Output is correct
45 Correct 0 ms 36356 KB Output is correct
46 Correct 0 ms 36356 KB Output is correct
47 Correct 0 ms 36356 KB Output is correct
48 Correct 0 ms 36356 KB Output is correct
49 Correct 0 ms 36356 KB Output is correct
50 Correct 0 ms 36356 KB Output is correct
51 Correct 0 ms 36356 KB Output is correct
52 Correct 0 ms 36356 KB Output is correct
53 Correct 0 ms 36356 KB Output is correct
54 Correct 0 ms 36356 KB Output is correct
55 Correct 0 ms 36356 KB Output is correct
56 Correct 0 ms 36356 KB Output is correct
57 Correct 0 ms 36356 KB Output is correct
58 Correct 0 ms 36356 KB Output is correct
59 Correct 0 ms 36356 KB Output is correct
60 Correct 0 ms 36356 KB Output is correct
61 Correct 0 ms 36356 KB Output is correct
62 Correct 0 ms 36356 KB Output is correct
63 Correct 0 ms 36356 KB Output is correct
64 Correct 0 ms 36356 KB Output is correct
65 Correct 0 ms 36356 KB Output is correct
66 Correct 0 ms 36356 KB Output is correct
67 Correct 0 ms 36356 KB Output is correct
68 Correct 0 ms 36356 KB Output is correct
69 Correct 0 ms 36356 KB Output is correct
70 Correct 0 ms 36356 KB Output is correct
71 Correct 0 ms 36356 KB Output is correct
72 Correct 0 ms 36356 KB Output is correct
73 Correct 0 ms 36356 KB Output is correct
74 Correct 0 ms 36356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 36356 KB Output is correct
2 Correct 0 ms 36356 KB Output is correct
3 Correct 0 ms 36356 KB Output is correct
4 Correct 0 ms 36356 KB Output is correct
5 Correct 0 ms 36356 KB Output is correct
6 Correct 0 ms 36356 KB Output is correct
7 Correct 0 ms 36356 KB Output is correct
8 Correct 0 ms 36356 KB Output is correct
9 Correct 0 ms 36356 KB Output is correct
10 Correct 0 ms 36356 KB Output is correct
11 Correct 0 ms 36356 KB Output is correct
12 Correct 0 ms 36356 KB Output is correct
13 Correct 0 ms 36356 KB Output is correct
14 Correct 0 ms 36356 KB Output is correct
15 Correct 0 ms 36356 KB Output is correct
16 Correct 0 ms 36356 KB Output is correct
17 Correct 0 ms 36356 KB Output is correct
18 Correct 0 ms 36356 KB Output is correct
19 Correct 0 ms 36356 KB Output is correct
20 Correct 0 ms 36356 KB Output is correct
21 Correct 0 ms 36356 KB Output is correct
22 Correct 0 ms 36356 KB Output is correct
23 Correct 0 ms 36356 KB Output is correct
24 Correct 0 ms 36356 KB Output is correct
25 Correct 0 ms 36356 KB Output is correct
26 Correct 0 ms 36356 KB Output is correct
27 Correct 0 ms 36356 KB Output is correct
28 Correct 0 ms 36356 KB Output is correct
29 Correct 0 ms 36356 KB Output is correct
30 Correct 0 ms 36356 KB Output is correct
31 Correct 0 ms 36356 KB Output is correct
32 Correct 0 ms 36356 KB Output is correct
33 Correct 0 ms 36356 KB Output is correct
34 Correct 0 ms 36356 KB Output is correct
35 Correct 0 ms 36356 KB Output is correct
36 Correct 0 ms 36356 KB Output is correct
37 Correct 0 ms 36356 KB Output is correct
38 Correct 0 ms 36356 KB Output is correct
39 Correct 0 ms 36356 KB Output is correct
40 Correct 0 ms 36356 KB Output is correct
41 Correct 0 ms 36356 KB Output is correct
42 Correct 0 ms 36356 KB Output is correct
43 Correct 0 ms 36356 KB Output is correct
44 Correct 0 ms 36356 KB Output is correct
45 Correct 0 ms 36356 KB Output is correct
46 Correct 0 ms 36356 KB Output is correct
47 Correct 0 ms 36356 KB Output is correct
48 Correct 0 ms 36356 KB Output is correct
49 Correct 0 ms 36356 KB Output is correct
50 Correct 0 ms 36356 KB Output is correct
51 Correct 0 ms 36356 KB Output is correct
52 Correct 6 ms 36356 KB Output is correct
53 Correct 13 ms 36356 KB Output is correct
54 Correct 33 ms 36356 KB Output is correct
55 Correct 29 ms 36356 KB Output is correct
56 Correct 89 ms 36356 KB Output is correct
57 Correct 76 ms 36356 KB Output is correct
58 Correct 106 ms 36356 KB Output is correct
59 Correct 126 ms 36356 KB Output is correct
60 Correct 229 ms 36356 KB Output is correct
61 Correct 0 ms 36356 KB Output is correct
62 Correct 13 ms 36356 KB Output is correct
63 Correct 29 ms 36356 KB Output is correct
64 Correct 23 ms 36356 KB Output is correct
65 Correct 43 ms 36356 KB Output is correct
66 Correct 63 ms 36356 KB Output is correct
67 Correct 283 ms 36356 KB Output is correct
68 Correct 89 ms 36356 KB Output is correct
69 Correct 73 ms 36356 KB Output is correct