Submission #905882

# Submission time Handle Problem Language Result Execution time Memory
905882 2024-01-13T06:13:39 Z Faisal_Saqib Bali Sculptures (APIO15_sculpture) C++17
0 / 100
1 ms 348 KB
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
using namespace std;
#define ll long long
const ll inf=1e18;
const ll N=200;
ll aps[N];
ll pre[N];
ll dp[N][N];
bool pos[N][N];
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	for(int i=0;i<n;i++)
	{
		cin>>aps[i];
		pre[i+1]=aps[i]+pre[i];
	}
	// ll pos=(1ll<<21)-1;
	// for(int i=20;i>=0;i--)
	// {
	// 	ll new_pos=pos-(1ll<<i);
		// Can i spilt the array in segement so that the final_or let that be b so that the bit off in pos are off  in b
		// dp[i][j] let spilt the prefix i into j part so what is the minimum or possible
		for(int i=0;i<=n;i++)
			for(int j=0;j<=n;j++)
				dp[i][j]=inf;
		dp[0][0]=0;
		pos[0][0]=1;
		// bool pos=0;
		ll ans=inf;
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=i;j++)
			{
				for(int k=0;k<i;k++)
				{
					if(pos[k][j-1])
					{
						dp[i][j]=min(dp[i][j],(dp[k][j-1]|(pre[i]-pre[k])));
						pos[i][j]=1;
					}
				}
				if(i==n and a<=j and j<=b and pos[i][j])
				{
					ans=min(ans,dp[i][j]);
				}
			}
		}
		cout<<ans<<endl;
	// 	if(pos)
	// 	{
	// 		pos=new_pos;
	// 	}
	// }
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -