結果
問題 | No.2071 Shift and OR |
ユーザー |
![]() |
提出日時 | 2023-03-03 09:20:25 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 53 ms / 2,000 ms |
コード長 | 1,374 bytes |
コンパイル時間 | 3,500 ms |
コンパイル使用メモリ | 252,860 KB |
最終ジャッジ日時 | 2025-02-11 01:21:51 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 |
ソースコード
#include <bits/stdc++.h>#include <atcoder/all>using namespace atcoder;using namespace std;using ll=long long;using ld=double;ld pie=3.14159265359;ll mod=998244353;long long inf=100000000000000001;int main(){ll n;cin >> n;vector<ll>a(n);for (ll i = 0; i < n; i++){cin >> a[i];}vector<ll>two(17,1);for (ll i = 1; i <=16; i++){two[i]=two[i-1]*2;}if (n>=16){ll ans=0;for (ll i = 0; i < 16; i++){ans+=two[i];}cout << ans << endl;return 0;}ll dai=0;for (ll i = 0; i < 16; i++){dai+=two[i];}vector<vector<ll>>dp(n+1,vector<ll>(dai+10,0));dp[0][0]=1;for (ll i = 0; i < n; i++){vector<ll>b;for (ll j = 0; j < 16; j++){b.push_back(a[i]);if (a[i]%2){a[i]+=two[16];}a[i]/=2;}for (ll j = 0; j <= dai; j++){for (ll k = 0; k < b.size(); k++){ll x=j;x=x|b[k];dp[i+1][x]+=dp[i][j];}}}ll ans=0;for (ll i = 0; i < dp[n].size(); i++){if (dp[n][i]>=1){ans=i;}}cout << ans << endl;}