답안 #205330

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
205330 2020-02-28T15:06:12 Z kshitij_sodani Bali Sculptures (APIO15_sculpture) C++17
0 / 100
5 ms 380 KB
#include <iostream>
#include <bits/stdc++.h>
 
using namespace std;
typedef int64_t llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
#define endl "\n"
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	llo n,a,b;
	cin>>n>>a>>b;
	llo it[n];
	for(llo i=0;i<n;i++){
		cin>>it[i];
	}
	llo dp[n];
	llo ans=0;

	memset(dp,0,sizeof(dp));
	llo pre[n];
	pre[0]=it[0];

	for(llo i=1;i<n;i++){
		pre[i]=pre[i-1]+it[i];
	}
	
	for(llo i=42;i>=0;i--){
		memset(dp,0,sizeof(dp));
		//cout<<ans<<endl;
		ans=ans+(((llo)1<<(i))-(llo)1);
	//	cout<<i<<endl;
		//cout<<ans<<endl;
		for(llo j=0;j<n;j++){

				llo no=pre[j];
				no|=ans;
				if(no==ans){
					dp[j]=1;
				}				
				for(llo l=0;l<j;l++){

					llo no=(pre[j]-pre[l]);
					no|=ans;
					if(dp[l]==1 and (no==ans)){
						if(dp[j]==0){
							dp[j]=dp[l]+1;
						}
						dp[j]=min(dp[j],dp[l]+1);
					}
				}
			
		}
		ans-=(llo)(((llo)1<<(i))-(llo)1);
		//cout<<ans<<endl<<endl;
		llo st=1;
		for(llo j=n-1;j<n;j++){
			if(dp[j]>0 and dp[j]<b+1){
				st=0;
				break;
			}
		}
		if(st){
			ans|=((llo)1<<i);
		}
	}
	
	cout<<ans<<endl;
	/*llo nno=8|3;
	//cout<<nno<<endl;
 
 
 */
 
 
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Incorrect 5 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Incorrect 5 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Incorrect 5 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 376 KB Output is correct
2 Incorrect 5 ms 380 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Incorrect 5 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -