Submission #40473

# Submission time Handle Problem Language Result Execution time Memory
40473 2018-02-01T21:47:37 Z MatheusLealV Bali Sculptures (APIO15_sculpture) C++14
0 / 100
2 ms 712 KB
#include <bits/stdc++.h>
#define N 205
#define inf 300000000000000000LL
using namespace std;
typedef long long ll;

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

ll dp[N][N], sum[N], ans = inf;

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] = inf;

			if(i < k) continue;

			for(int j = 1; j <= i; j++)
			{
				if(j - 1 < 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 2 ms 484 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 484 KB Output is correct
2 Incorrect 1 ms 488 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 520 KB Output is correct
2 Incorrect 1 ms 520 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 520 KB Output is correct
2 Incorrect 1 ms 540 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 540 KB Output is correct
2 Incorrect 1 ms 712 KB Output isn't correct
3 Halted 0 ms 0 KB -