Submission #629788

# Submission time Handle Problem Language Result Execution time Memory
629788 2022-08-15T06:31:28 Z aebov Bali Sculptures (APIO15_sculpture) C++17
Compilation error
0 ms 0 KB
#include<iostream>
#include<algorithm>
#include<bitset>
#include<vector>
#define ll long long
#define pb push_back
using namespace std;
 
ll dp[2001];
int n,a,b,y[2001];
ll inf = (1LL<<57);
ll ans = (1LL<<57)-1;
bool f()
{
	for(int i=0;i<=n;i++)dp[i]=inf;
	dp[0]=0;
	for(int i=0;i<n;i++){
		ll sum=0;
		for(int j=i;j<n;j++)
		{
			sum += y[j];
			if((sum|ans)==ans)dp[j + 1] = min(dp[j + 1], 1 + dp[i]);
		}
	}
	return dp[n]<=b;
}
void do_job(int pos,int sep,ll sum, ll ret)
{
	if(pos==n){
		if(a<=sep && sep<=b)ans=min(ans,sum|ret);
		return;
	}
	do_job(pos+1,sep,sum+y[pos],ret);
	do_job(pos+1,sep+1,y[pos],sum|ret);
}
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>a>>b;
	for(int i=0;i<n;i++)cin>>y[i];

	if(n<=50){
		do_job(1,1,y[0],0)
		cout<<ans<<endl;
		return 0;
	}
	for(int i=56;i>=0;i--){
		ans^=(1LL<<i);
		if(!f())ans|=(1LL<<i);
	}
	cout<<ans<<endl;
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:43:21: error: expected ';' before 'cout'
   43 |   do_job(1,1,y[0],0)
      |                     ^
      |                     ;
   44 |   cout<<ans<<endl;
      |   ~~~~