# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
629785 | 2022-08-15T06:25:18 Z | aebov | Bali Sculptures (APIO15_sculpture) | C++17 | 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); 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; } 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]; ll ans = (1LL<<57)-1; for(int i=56;i>=0;i--){ ans^=(1LL<<i); if(f)ans|=(1LL<<i); } cout<<ans<<endl; }