結果
| 問題 | No.2071 Shift and OR | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2022-10-16 20:54:33 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 71 ms / 2,000 ms | 
| コード長 | 770 bytes | 
| コンパイル時間 | 2,106 ms | 
| コンパイル使用メモリ | 197,432 KB | 
| 最終ジャッジ日時 | 2025-02-08 07:17:18 | 
| ジャッジサーバーID (参考情報) | judge1 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 37 | 
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int N; cin >> N;
    if(N >= 16) {
        cout << (1 << 16) - 1 << endl;
    } else {
        vector<int> A(N);
        rep(i,N) cin >> A[i];
        int LIM = (1 << 16);
        vector<vector<int>> dp(N + 1, vector<int>(LIM, 0));
        dp[0][0] = 1;
        rep(i,N) {
            rep(x,LIM) {
                rep(_,15) {
                    dp[i + 1][x | A[i]] |= dp[i][x];
                    A[i] = (A[i] / 2) + (1 << 15) * (A[i] % 2);
                }
            }
        }
        int ans = 0;
        rep(x,LIM) if(dp[N][x]) ans = max(ans, x);
        cout << ans << endl;
    }
}
            
            
            
        