結果
| 問題 | No.2071 Shift and OR | 
| コンテスト | |
| ユーザー |  umezo | 
| 提出日時 | 2022-09-17 20:47:26 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 32 ms / 2,000 ms | 
| コード長 | 746 bytes | 
| コンパイル時間 | 1,998 ms | 
| コンパイル使用メモリ | 195,472 KB | 
| 最終ジャッジ日時 | 2025-02-07 11:29:02 | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 37 | 
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int dp[16][700000];
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n;
  cin>>n;
  vector<int> A(n);
  rep(i,n) cin>>A[i];
  
  if(n>=16){
    cout<<(1<<16)-1<<endl;
    return 0;
  }
  
  dp[0][0]=1;
  for(int i=0;i<n;i++){
    vector<int> B(16);
    B[0]=A[i];
    for(int j=1;j<16;j++){
      B[j]=B[j-1]/2;
      if(B[j-1]%2) B[j]+=(1<<15);
    }
    for(int j=0;j<(1<<16);j++){
      for(int k=0;k<16;k++){
        dp[i+1][j|B[k]]|=dp[i][j];
      }
    }
  }
  int ma=0;
  for(int i=0;i<(1<<16);i++){
    if(dp[n][i]) ma=i;
  }
  cout<<ma<<endl;
  
  return 0;
}
            
            
            
        