結果
問題 | No.2071 Shift and OR |
ユーザー |
|
提出日時 | 2022-09-16 21:31:55 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 59 ms / 2,000 ms |
コード長 | 811 bytes |
コンパイル時間 | 1,894 ms |
コンパイル使用メモリ | 175,644 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-21 18:28:12 |
合計ジャッジ時間 | 3,766 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ auto f = [&](int x){return x / 2 + (1 << 15) * (x & 1);}; int n; cin >> n; vector<int> a(n); for(auto &&v:a)cin >> v; if(n >= 16){ cout << (1 << 16) - 1 << '\n'; return 0; } vector<vector<bool>> dp(n + 1, vector<bool>(1 << 16)); dp[0][0] = true; for(int i = 0; i < n; i++){ vector<int> b; for(int j = 0; j < 16; j++){ b.push_back(a[i]); a[i] = f(a[i]); } for(int j = 0; j < (1 << 16); j++){ if(dp[i][j]){ for(auto &&S:b)dp[i + 1][j | S] = true; } } } for(int j = (1 << 16) - 1; j >= 0; j--){ if(dp[n][j]){ cout << j << '\n'; return 0; } } }