結果

問題 No.2071 Shift and OR
ユーザー asaringoasaringo
提出日時 2022-09-16 22:04:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 1,176 bytes
コンパイル時間 2,023 ms
コンパイル使用メモリ 197,228 KB
実行使用メモリ 6,028 KB
最終ジャッジ日時 2023-08-23 15:38:51
合計ジャッジ時間 3,697 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 7 ms
4,384 KB
testcase_04 AC 4 ms
4,380 KB
testcase_05 AC 12 ms
5,796 KB
testcase_06 AC 4 ms
4,376 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 AC 5 ms
4,376 KB
testcase_10 AC 4 ms
4,380 KB
testcase_11 AC 14 ms
5,956 KB
testcase_12 AC 15 ms
5,824 KB
testcase_13 AC 12 ms
5,812 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 9 ms
5,796 KB
testcase_16 AC 9 ms
5,792 KB
testcase_17 AC 13 ms
5,820 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 17 ms
5,796 KB
testcase_20 AC 16 ms
5,808 KB
testcase_21 AC 20 ms
6,028 KB
testcase_22 AC 18 ms
5,804 KB
testcase_23 AC 17 ms
4,380 KB
testcase_24 AC 3 ms
4,376 KB
testcase_25 AC 9 ms
4,380 KB
testcase_26 AC 10 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 18 ms
4,380 KB
testcase_29 AC 18 ms
4,380 KB
testcase_30 AC 7 ms
4,380 KB
testcase_31 AC 4 ms
4,376 KB
testcase_32 AC 4 ms
4,380 KB
testcase_33 AC 5 ms
4,376 KB
testcase_34 AC 5 ms
4,384 KB
testcase_35 AC 6 ms
4,376 KB
testcase_36 AC 7 ms
4,380 KB
testcase_37 AC 5 ms
4,376 KB
testcase_38 AC 4 ms
4,380 KB
testcase_39 AC 4 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std ;
#define fast_input_output ios::sync_with_stdio(false); cin.tie(nullptr);
typedef long long ll ;
typedef long double ld ;
typedef pair<ll,ll> P ;
typedef tuple<ll,ll,ll> TP ;
#define chmin(a,b) a = min(a,b)
#define chmax(a,b) a = max(a,b)
#define bit_count(x) __builtin_popcountll(x)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a / gcd(a,b) * b
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define rrep(i,a,b) for(int i = a ; i < b ; i++)
#define endl "\n"

int n ;
int A[202020];
bool dp[18][1 << 18] ;

int main(){
    fast_input_output
    cin >> n ;
    rep(i,n) cin >> A[i];
    if(n > 16) {
        cout << (1LL << 16) - 1 << endl;
        return 0;
    }
    dp[0][0] = true;
    rep(i,n){
        int a = A[i];
        rep(S,1<<16){
            if(!dp[i][S]) continue;
            rep(j,20){
                dp[i+1][S | a] = true;
                if(a & 1){
                    a /= 2;
                    a += (1 << 15);
                }
                else{
                    a /= 2;
                }
            }
        }
    }
    int res = 0;
    rep(S,1<<17) if(dp[n][S]) res = S;
    cout << res << endl;
}
0