結果
問題 | No.2071 Shift and OR |
ユーザー | kens |
提出日時 | 2022-09-16 21:52:28 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 62 ms / 2,000 ms |
コード長 | 614 bytes |
コンパイル時間 | 2,299 ms |
コンパイル使用メモリ | 203,108 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-21 19:09:43 |
合計ジャッジ時間 | 4,099 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 |
ソースコード
#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; }