Submission #170797

# Submission time Handle Problem Language Result Execution time Memory
170797 2019-12-26T11:25:44 Z Nightmar Bali Sculptures (APIO15_sculpture) C++17
0 / 100
2 ms 376 KB
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <iomanip>
 
#define SWS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define ppb pop_back
#define ft first
#define sd second
#define read freopen("input.txt", "r", stdin)
#define write freopen("output.txt", "w", stdout)
#define files read; write
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
 
const int Z = (int)2e3 + 228;
const int N = (int)3e5 + 228;
const int INF = (int)1e9 + 228;
const int MOD = (int)1e9 + 7;
const ll LLINF = (ll)1e18 + 228;

ll a[Z], pref[Z];
ll dp[Z][Z];

int main()
{
	SWS;
	//files;
	int n, l, r;
	cin >> n >> l >> r;
	for (int i = 1; i <= n; i++) 
	{
		cin >> a[i];
		pref[i] = pref[i - 1] + a[i];
	}
	ll ans = LLINF;
	for (int kek = l; kek <= r; kek++)
	{
		for (int i = 1; i <= n; i++)
			for (int team = 1; team <= kek; team++)
				dp[i][team] = LLINF;
		if (kek == 1)
		{
			for (int i = 1; i <= n; i++)
				dp[i][kek] = pref[i];
			ans = dp[n][kek];
			continue;
		}
		for (int i = 1; i <= n; i++)
			for (int team = 1; team <= min(i, kek); team++)
			{ 
				for (int j = team - 1; j < i; j++)
				{
					ll cur = dp[j][team - 1] | (pref[i] - pref[j - 1]);
					dp[i][team] = min(dp[i][team], cur);
				}
			}
		ans = min(ans, dp[n][kek]);
		//cout << kek << ' ' << dp[n][kek] << ' ' << dp[3][1] << endl;
	}
	cout << ans;
	return 0;
}
/*
6 1 3
8 1 2 1 5 4
*/
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 352 KB Output isn't correct
3 Halted 0 ms 0 KB -