結果

問題 No.2071 Shift and OR
ユーザー SSRSSSRS
提出日時 2022-09-16 21:25:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 803 bytes
コンパイル時間 1,728 ms
コンパイル使用メモリ 172,500 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-23 14:24:32
合計ジャッジ時間 3,459 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  if (N >= 16){
    cout << (1 << 16) - 1 << endl;
  } else {
    vector<vector<bool>> dp(N + 1, vector<bool>(1 << 16, false));
    dp[0][0] = true;
    for (int i = 0; i < N; i++){
      vector<int> B(16);
      B[0] = A[i];
      for (int j = 0; j < 15; j++){
        B[j + 1] = B[j] / 2 + ((B[j] % 2) << 15);
      }
      for (int j = 0; j < (1 << 16); j++){
        if (dp[i][j]){
          for (int k = 0; k < 16; k++){
            dp[i + 1][j | B[k]] = true;
          }
        }
      }
    }
    int ans = 0;
    for (int i = 0; i < (1 << 16); i++){
      if (dp[N][i]){
        ans = max(ans, i);
      }
    }
    cout << ans << endl;
  }
}
0