답안 #31130

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
31130 2017-08-10T22:35:33 Z nibnalin Bali Sculptures (APIO15_sculpture) C++14
21 / 100
0 ms 33440 KB
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

typedef long long int lli;

const lli maxn = lli(2e3)+5, inf = lli(1e14)+5;

lli n, A[maxn], memo[maxn][maxn];

lli DP(lli idx, lli p)
{
	if(idx == n+1 && !p) return 0;
	else if(p < 0) return inf;
	else if(memo[idx][p] != -1) return memo[idx][p];
	else
	{
		lli res = inf;
		for(lli i = idx;i <= n;i++)
		{
			res = min(res, DP(i+1, p-1)|(A[i]-A[idx-1]));
		}
		//cout << idx << " " << p << " " << res << "\n";
		return memo[idx][p] = res;
	}
}

int main(void)
{
	lli a, b;
	scanf("%lld%lld%lld", &n, &a, &b);

	for(lli i = 0;i <= n;i++)
	{
		for(lli j = 0;j <= n;j++) memo[i][j] = -1;
	}

	for(lli i = 1;i <= n;i++) scanf("%lld", &A[i]);

	for(lli i = 1;i <= n;i++) A[i] += A[i-1];

	printf("%lld\n", DP(1, b));
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:32:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld%lld", &n, &a, &b);
                                   ^
sculpture.cpp:39:48: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(lli i = 1;i <= n;i++) scanf("%lld", &A[i]);
                                                ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 33440 KB Output is correct
2 Correct 0 ms 33440 KB Output is correct
3 Correct 0 ms 33440 KB Output is correct
4 Correct 0 ms 33440 KB Output is correct
5 Correct 0 ms 33440 KB Output is correct
6 Correct 0 ms 33440 KB Output is correct
7 Correct 0 ms 33440 KB Output is correct
8 Correct 0 ms 33440 KB Output is correct
9 Correct 0 ms 33440 KB Output is correct
10 Correct 0 ms 33440 KB Output is correct
11 Correct 0 ms 33440 KB Output is correct
12 Correct 0 ms 33440 KB Output is correct
13 Correct 0 ms 33440 KB Output is correct
14 Correct 0 ms 33440 KB Output is correct
15 Incorrect 0 ms 33440 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 33440 KB Output is correct
2 Correct 0 ms 33440 KB Output is correct
3 Correct 0 ms 33440 KB Output is correct
4 Correct 0 ms 33440 KB Output is correct
5 Correct 0 ms 33440 KB Output is correct
6 Correct 0 ms 33440 KB Output is correct
7 Correct 0 ms 33440 KB Output is correct
8 Correct 0 ms 33440 KB Output is correct
9 Correct 0 ms 33440 KB Output is correct
10 Correct 0 ms 33440 KB Output is correct
11 Correct 0 ms 33440 KB Output is correct
12 Correct 0 ms 33440 KB Output is correct
13 Correct 0 ms 33440 KB Output is correct
14 Correct 0 ms 33440 KB Output is correct
15 Incorrect 0 ms 33440 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 33440 KB Output is correct
2 Correct 0 ms 33440 KB Output is correct
3 Correct 0 ms 33440 KB Output is correct
4 Correct 0 ms 33440 KB Output is correct
5 Correct 0 ms 33440 KB Output is correct
6 Correct 0 ms 33440 KB Output is correct
7 Correct 0 ms 33440 KB Output is correct
8 Correct 0 ms 33440 KB Output is correct
9 Correct 0 ms 33440 KB Output is correct
10 Correct 0 ms 33440 KB Output is correct
11 Correct 0 ms 33440 KB Output is correct
12 Correct 0 ms 33440 KB Output is correct
13 Correct 0 ms 33440 KB Output is correct
14 Correct 0 ms 33440 KB Output is correct
15 Correct 0 ms 33440 KB Output is correct
16 Correct 0 ms 33440 KB Output is correct
17 Correct 0 ms 33440 KB Output is correct
18 Correct 0 ms 33440 KB Output is correct
19 Correct 0 ms 33440 KB Output is correct
20 Correct 0 ms 33440 KB Output is correct
21 Correct 0 ms 33440 KB Output is correct
22 Correct 0 ms 33440 KB Output is correct
23 Correct 0 ms 33440 KB Output is correct
24 Correct 0 ms 33440 KB Output is correct
25 Correct 0 ms 33440 KB Output is correct
26 Correct 0 ms 33440 KB Output is correct
27 Correct 0 ms 33440 KB Output is correct
28 Correct 0 ms 33440 KB Output is correct
29 Correct 0 ms 33440 KB Output is correct
30 Correct 0 ms 33440 KB Output is correct
31 Correct 0 ms 33440 KB Output is correct
32 Correct 0 ms 33440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 33440 KB Output is correct
2 Correct 0 ms 33440 KB Output is correct
3 Correct 0 ms 33440 KB Output is correct
4 Correct 0 ms 33440 KB Output is correct
5 Correct 0 ms 33440 KB Output is correct
6 Correct 0 ms 33440 KB Output is correct
7 Correct 0 ms 33440 KB Output is correct
8 Correct 0 ms 33440 KB Output is correct
9 Correct 0 ms 33440 KB Output is correct
10 Correct 0 ms 33440 KB Output is correct
11 Correct 0 ms 33440 KB Output is correct
12 Correct 0 ms 33440 KB Output is correct
13 Correct 0 ms 33440 KB Output is correct
14 Correct 0 ms 33440 KB Output is correct
15 Incorrect 0 ms 33440 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 33440 KB Output is correct
2 Correct 0 ms 33440 KB Output is correct
3 Correct 0 ms 33440 KB Output is correct
4 Correct 0 ms 33440 KB Output is correct
5 Correct 0 ms 33440 KB Output is correct
6 Correct 0 ms 33440 KB Output is correct
7 Correct 0 ms 33440 KB Output is correct
8 Correct 0 ms 33440 KB Output is correct
9 Correct 0 ms 33440 KB Output is correct
10 Correct 0 ms 33440 KB Output is correct
11 Correct 0 ms 33440 KB Output is correct
12 Correct 0 ms 33440 KB Output is correct
13 Correct 0 ms 33440 KB Output is correct
14 Correct 0 ms 33440 KB Output is correct
15 Correct 0 ms 33440 KB Output is correct
16 Correct 0 ms 33440 KB Output is correct
17 Correct 0 ms 33440 KB Output is correct
18 Incorrect 0 ms 33440 KB Output isn't correct
19 Halted 0 ms 0 KB -