Submission #699812

#TimeUsernameProblemLanguageResultExecution timeMemory
699812Abrar_Al_SamitBali Sculptures (APIO15_sculpture)C++17
71 / 100
313 ms460 KiB
#include<bits/stdc++.h>
using namespace std;

const int nax = 101;
int n, a, b;

long long ans;
int curBit;
int dp[nax][nax];
int tree[nax];

bool good(long long S) {
  if(S>>curBit&1) return false;
  for(int j=curBit+1; j<60; ++j) {
    if((S>>j&1) && (~ans>>j&1)) return false;
  }
  return true;
}
int solve(int i, int j) {
  if(i>n) return j>=a && j<=b;
  int &ret = dp[i][j];
  if(ret!=-1) return ret;
  ret = 0;

  long long S = 0;
  for(int k=i; k<=n; ++k) {
    S += tree[k];
    if(good(S)) ret |= solve(k+1, j+1);
  }
  return ret;
}
void PlayGround() {
  cin>>n>>a>>b;
  for(int i=1; i<=n; ++i) {
    cin>>tree[i];
  }

  for(int i=59; i>=0; --i) {
    curBit = i;
    memset(dp, -1, sizeof dp);
    if(!solve(1, 0)) ans |= 1LL<<i;
  }
  cout<<ans<<'\n';

  // cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  PlayGround();
  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...