結果
| 問題 |
No.2071 Shift and OR
|
| コンテスト | |
| ユーザー |
eve__fuyuki
|
| 提出日時 | 2024-05-03 17:43:12 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 47 ms / 2,000 ms |
| コード長 | 907 bytes |
| コンパイル時間 | 1,999 ms |
| コンパイル使用メモリ | 199,232 KB |
| 最終ジャッジ日時 | 2025-02-21 10:46:09 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
void fast_io() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
}
int main() {
fast_io();
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;
return 0;
}
vector<vector<bool>> dp(n + 1, vector<bool>(1 << 16));
dp[0][0] = true;
for (int i = 0; i < n; i++) {
for (int j = 0; j < 1 << 16; j++) {
if (dp[i][j]) {
int num = a[i];
for (int _ = 0; _ < 16; _++) {
dp[i + 1][j | num] = true;
num = num / 2 + (num % 2) * (1 << 15);
}
}
}
}
for (int i = (1 << 16) - 1; i >= 0; i--) {
if (dp[n][i]) {
cout << i << endl;
return 0;
}
}
}
eve__fuyuki