結果

問題 No.2071 Shift and OR
ユーザー RubikunRubikun
提出日時 2022-09-16 21:22:44
言語 C++17
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 1,185 bytes
コンパイル時間 2,037 ms
使用メモリ 4,464 KB
最終ジャッジ日時 2023-01-11 05:51:24
合計ジャッジ時間 5,575 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 6 ms
3,528 KB
testcase_01 AC 8 ms
3,692 KB
testcase_02 AC 12 ms
3,872 KB
testcase_03 AC 17 ms
3,948 KB
testcase_04 AC 15 ms
3,852 KB
testcase_05 AC 24 ms
4,104 KB
testcase_06 AC 15 ms
3,904 KB
testcase_07 AC 13 ms
3,864 KB
testcase_08 AC 15 ms
3,780 KB
testcase_09 AC 15 ms
3,892 KB
testcase_10 AC 15 ms
3,884 KB
testcase_11 AC 26 ms
4,240 KB
testcase_12 AC 26 ms
4,104 KB
testcase_13 AC 24 ms
4,040 KB
testcase_14 AC 4 ms
3,656 KB
testcase_15 AC 20 ms
3,916 KB
testcase_16 AC 20 ms
4,072 KB
testcase_17 AC 27 ms
4,208 KB
testcase_18 AC 8 ms
3,596 KB
testcase_19 AC 28 ms
4,316 KB
testcase_20 AC 28 ms
4,304 KB
testcase_21 AC 35 ms
4,464 KB
testcase_22 AC 29 ms
4,352 KB
testcase_23 AC 17 ms
4,212 KB
testcase_24 AC 3 ms
3,632 KB
testcase_25 AC 9 ms
3,756 KB
testcase_26 AC 10 ms
3,708 KB
testcase_27 AC 2 ms
3,596 KB
testcase_28 AC 18 ms
4,156 KB
testcase_29 AC 18 ms
4,104 KB
testcase_30 AC 17 ms
3,948 KB
testcase_31 AC 18 ms
3,916 KB
testcase_32 AC 18 ms
4,036 KB
testcase_33 AC 17 ms
3,968 KB
testcase_34 AC 18 ms
3,912 KB
testcase_35 AC 18 ms
4,036 KB
testcase_36 AC 18 ms
3,960 KB
testcase_37 AC 17 ms
3,956 KB
testcase_38 AC 17 ms
3,956 KB
testcase_39 AC 17 ms
3,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=300005,INF=1<<30;

bool dp[22][1<<16];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    vector<int> A;
    for(int i=0;i<N;i++){
        int x;cin>>x;
        if(x){
            A.push_back(x);
        }
    }
    N=si(A);
    if(N>=16){
        cout<<(1<<16)-1<<endl;
        return 0;
    }
    
    dp[0][0]=1;
    for(int i=0;i<N;i++){
        int x=A[i];
        for(int j=0;j<(1<<16);j++){
            for(int k=0;k<16;k++){
                dp[i+1][j|x]|=dp[i][j];
                x=(x/2)+((x&1)<<15);
            }
        }
    }
    
    for(int i=(1<<16)-1;i>=0;i--){
        if(dp[N][i]){
            cout<<i<<endl;
            return 0;
        }
    }
}
0