Submission #40466

# Submission time Handle Problem Language Result Execution time Memory
40466 2018-02-01T21:14:42 Z MatheusLealV Bali Sculptures (APIO15_sculpture) C++14
0 / 100
2 ms 660 KB
#include <bits/stdc++.h>
#define N 2005
using namespace std;
typedef long long ll;

int n, A, B, v[N];

ll dp[N][N], sum[N], ans = 200000000000000000LL;

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

	cin>>n>>A>>B;

	for(int i = 1; i <= n; i++)
	{
		cin>>v[i], sum[i] = sum[i - 1] + (ll)v[i], dp[i][1] = sum[i];

		if(A <= 1 && 1 <= B && i == n) ans = min(ans, dp[i][1]);
	}

	for(int k = 2; k <= B; k++)
	{
		for(int i = 1; i <= n; i++)
		{
			dp[i][k] = 200000000000000000LL;

			for(int j = 1; j <= i; j++)
			{
				if(j < k - 1) continue;

				dp[i][k] = min( (dp[j - 1][k - 1] | (sum[i] - sum[j - 1])), dp[i][k]);

				//cout<<dp[j - 1][k - 1]<<" "<<(sum[i] - sum[j - 1])<<" "<<(dp[j - 1][k - 1] | (sum[i] - sum[j - 1]))<<"\n";
			}

			if(A <= k && k <= B && i == n) ans = min(ans, dp[i][k]);

			//cout<<i<<" "<<k<<" "<<dp[i][k]<<"\n";
		}
	}

	cout<<ans<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 376 KB Output is correct
2 Incorrect 1 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 404 KB Output is correct
2 Incorrect 1 ms 460 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 460 KB Output is correct
2 Incorrect 2 ms 660 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 660 KB Output is correct
2 Incorrect 1 ms 660 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 660 KB Output is correct
2 Incorrect 1 ms 660 KB Output isn't correct
3 Halted 0 ms 0 KB -