結果

問題 No.2071 Shift and OR
ユーザー umezoumezo
提出日時 2022-09-17 20:47:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 746 bytes
コンパイル時間 2,157 ms
コンパイル使用メモリ 203,852 KB
実行使用メモリ 7,424 KB
最終ジャッジ日時 2024-06-01 15:18:18
合計ジャッジ時間 3,864 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
6,812 KB
testcase_01 AC 7 ms
6,940 KB
testcase_02 AC 10 ms
6,940 KB
testcase_03 AC 13 ms
6,944 KB
testcase_04 AC 12 ms
6,944 KB
testcase_05 AC 17 ms
6,944 KB
testcase_06 AC 11 ms
6,940 KB
testcase_07 AC 10 ms
6,940 KB
testcase_08 AC 12 ms
6,940 KB
testcase_09 AC 11 ms
6,940 KB
testcase_10 AC 12 ms
6,944 KB
testcase_11 AC 19 ms
6,944 KB
testcase_12 AC 19 ms
6,940 KB
testcase_13 AC 18 ms
6,940 KB
testcase_14 AC 4 ms
6,940 KB
testcase_15 AC 14 ms
6,940 KB
testcase_16 AC 14 ms
6,940 KB
testcase_17 AC 19 ms
6,944 KB
testcase_18 AC 7 ms
6,940 KB
testcase_19 AC 21 ms
6,944 KB
testcase_20 AC 20 ms
6,940 KB
testcase_21 AC 25 ms
7,424 KB
testcase_22 AC 22 ms
6,948 KB
testcase_23 AC 19 ms
6,940 KB
testcase_24 AC 4 ms
6,940 KB
testcase_25 AC 10 ms
6,944 KB
testcase_26 AC 11 ms
6,944 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 20 ms
6,944 KB
testcase_29 AC 20 ms
6,940 KB
testcase_30 AC 13 ms
6,944 KB
testcase_31 AC 13 ms
6,940 KB
testcase_32 AC 13 ms
6,940 KB
testcase_33 AC 13 ms
6,944 KB
testcase_34 AC 13 ms
6,944 KB
testcase_35 AC 14 ms
6,940 KB
testcase_36 AC 13 ms
6,944 KB
testcase_37 AC 13 ms
6,940 KB
testcase_38 AC 14 ms
6,940 KB
testcase_39 AC 13 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0