結果

問題 No.2071 Shift and OR
ユーザー hiro71687khiro71687k
提出日時 2023-03-03 09:20:25
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 1,374 bytes
コンパイル時間 5,976 ms
コンパイル使用メモリ 264,160 KB
実行使用メモリ 12,088 KB
最終ジャッジ日時 2023-10-18 00:51:35
合計ジャッジ時間 8,994 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
5,488 KB
testcase_01 AC 9 ms
6,016 KB
testcase_02 AC 13 ms
7,072 KB
testcase_03 AC 16 ms
8,128 KB
testcase_04 AC 16 ms
7,600 KB
testcase_05 AC 22 ms
9,448 KB
testcase_06 AC 15 ms
7,600 KB
testcase_07 AC 13 ms
7,072 KB
testcase_08 AC 15 ms
7,600 KB
testcase_09 AC 15 ms
7,600 KB
testcase_10 AC 14 ms
7,600 KB
testcase_11 AC 26 ms
9,976 KB
testcase_12 AC 26 ms
9,976 KB
testcase_13 AC 22 ms
9,448 KB
testcase_14 AC 5 ms
4,960 KB
testcase_15 AC 19 ms
8,656 KB
testcase_16 AC 19 ms
8,656 KB
testcase_17 AC 25 ms
9,976 KB
testcase_18 AC 9 ms
6,016 KB
testcase_19 AC 27 ms
10,504 KB
testcase_20 AC 27 ms
10,504 KB
testcase_21 AC 34 ms
12,088 KB
testcase_22 AC 30 ms
11,032 KB
testcase_23 AC 52 ms
4,960 KB
testcase_24 AC 7 ms
4,348 KB
testcase_25 AC 25 ms
4,348 KB
testcase_26 AC 30 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 56 ms
4,960 KB
testcase_29 AC 57 ms
4,960 KB
testcase_30 AC 17 ms
8,128 KB
testcase_31 AC 17 ms
8,128 KB
testcase_32 AC 18 ms
8,128 KB
testcase_33 AC 18 ms
8,128 KB
testcase_34 AC 17 ms
8,128 KB
testcase_35 AC 18 ms
8,128 KB
testcase_36 AC 17 ms
8,128 KB
testcase_37 AC 17 ms
8,128 KB
testcase_38 AC 18 ms
8,128 KB
testcase_39 AC 17 ms
8,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0