結果
| 問題 | No.2071 Shift and OR | 
| コンテスト | |
| ユーザー |  houren | 
| 提出日時 | 2022-09-16 23:36:58 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 70 ms / 2,000 ms | 
| コード長 | 1,031 bytes | 
| コンパイル時間 | 2,186 ms | 
| コンパイル使用メモリ | 170,316 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-12-21 23:12:06 | 
| 合計ジャッジ時間 | 3,465 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 37 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define fix(x) fixed << setprecision(x)
#define asc(x) x, vector<x>, greater<x>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    if(n>=16){
        cout << (1<<16)-1 << '\n';
        return 0;
    }
    vector<bool> dp(1<<16, false);
    auto v = dp;
    dp[0] = true;
    rep(i,n){
        int a;
        cin >> a;
        auto dp2 = v;
        rep(j,16){
            rep(k,1<<16) if(dp[k]){
                dp2[a|k] = true;
            }
            a = (a >> 1) + (1 << 15) * (a & 1);
        }
        dp = dp2;
    }
    for(int i=(1<<16)-1;;i--){
        if(dp[i]){
            cout << i << '\n';
            return 0;
        }
    }
    return 0;
}
            
            
            
        