結果

問題 No.2071 Shift and OR
ユーザー kenskens
提出日時 2022-09-16 21:52:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 614 bytes
コンパイル時間 2,121 ms
コンパイル使用メモリ 201,792 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-23 14:59:07
合計ジャッジ時間 4,449 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,376 KB
testcase_01 AC 6 ms
4,376 KB
testcase_02 AC 7 ms
4,380 KB
testcase_03 AC 10 ms
4,380 KB
testcase_04 AC 9 ms
4,376 KB
testcase_05 AC 13 ms
4,380 KB
testcase_06 AC 9 ms
4,380 KB
testcase_07 AC 8 ms
4,380 KB
testcase_08 AC 8 ms
4,380 KB
testcase_09 AC 9 ms
4,380 KB
testcase_10 AC 9 ms
4,376 KB
testcase_11 AC 14 ms
4,380 KB
testcase_12 AC 14 ms
4,380 KB
testcase_13 AC 14 ms
4,376 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 11 ms
4,380 KB
testcase_16 AC 11 ms
4,376 KB
testcase_17 AC 14 ms
4,376 KB
testcase_18 AC 6 ms
4,376 KB
testcase_19 AC 15 ms
4,376 KB
testcase_20 AC 15 ms
4,376 KB
testcase_21 AC 19 ms
4,376 KB
testcase_22 AC 16 ms
4,380 KB
testcase_23 AC 48 ms
4,376 KB
testcase_24 AC 6 ms
4,380 KB
testcase_25 AC 23 ms
4,376 KB
testcase_26 AC 28 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 52 ms
4,376 KB
testcase_29 AC 53 ms
4,380 KB
testcase_30 AC 10 ms
4,376 KB
testcase_31 AC 10 ms
4,376 KB
testcase_32 AC 10 ms
4,380 KB
testcase_33 AC 11 ms
4,376 KB
testcase_34 AC 10 ms
4,376 KB
testcase_35 AC 10 ms
4,376 KB
testcase_36 AC 10 ms
4,380 KB
testcase_37 AC 10 ms
4,376 KB
testcase_38 AC 10 ms
4,380 KB
testcase_39 AC 10 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;

int shift(int x) {
  return x/2 + (1<<15)*(x % 2);
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int all = (1<<16)-1;
  if(n >= 16) {
    cout << all << endl;
    return 0;
  }
  vector<int> dp(1<<16);
  dp[0]++;
  rep(i,n) {
    vector<int> dpn(1<<16);
    rep(j,17) {
      a[i] = shift(a[i]);
      rep(x,1<<16) dpn[a[i]|x] += dp[x];
    }
    swap(dp,dpn);
  }
  int ans = 0;
  rep(i,1<<16) if(dp[i]) ans = max(ans,i);
  cout << ans << endl;
  return 0;
}
0