結果

問題 No.2071 Shift and OR
ユーザー norikamenorikame
提出日時 2022-09-17 00:53:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 232 ms / 2,000 ms
コード長 886 bytes
コンパイル時間 4,681 ms
コンパイル使用メモリ 267,252 KB
実行使用メモリ 8,444 KB
最終ジャッジ日時 2024-06-01 14:43:31
合計ジャッジ時間 8,660 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 9 ms
6,940 KB
testcase_03 AC 70 ms
6,944 KB
testcase_04 AC 31 ms
6,944 KB
testcase_05 AC 138 ms
6,944 KB
testcase_06 AC 43 ms
7,024 KB
testcase_07 AC 14 ms
6,944 KB
testcase_08 AC 24 ms
6,944 KB
testcase_09 AC 36 ms
6,940 KB
testcase_10 AC 44 ms
7,168 KB
testcase_11 AC 151 ms
7,652 KB
testcase_12 AC 152 ms
8,444 KB
testcase_13 AC 128 ms
7,568 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 95 ms
7,700 KB
testcase_16 AC 94 ms
7,588 KB
testcase_17 AC 151 ms
7,040 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 196 ms
8,388 KB
testcase_20 AC 167 ms
6,944 KB
testcase_21 AC 232 ms
6,940 KB
testcase_22 AC 219 ms
6,944 KB
testcase_23 AC 53 ms
6,940 KB
testcase_24 AC 7 ms
6,940 KB
testcase_25 AC 26 ms
6,944 KB
testcase_26 AC 30 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 58 ms
6,940 KB
testcase_29 AC 57 ms
6,944 KB
testcase_30 AC 79 ms
8,132 KB
testcase_31 AC 32 ms
6,940 KB
testcase_32 AC 35 ms
6,944 KB
testcase_33 AC 40 ms
6,948 KB
testcase_34 AC 52 ms
7,072 KB
testcase_35 AC 55 ms
7,872 KB
testcase_36 AC 75 ms
8,012 KB
testcase_37 AC 47 ms
6,940 KB
testcase_38 AC 40 ms
6,944 KB
testcase_39 AC 34 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// 

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

using ll = long long;

#define rep(i, n) for (int i=0; i<(int)(n); ++(i))
#define rep3(i, m, n) for (int i=(m); (i)<(int)(n); ++(i))
#define repr(i, n) for (int i=(int)(n)-1; (i)>=0; --(i))
#define rep3r(i, m, n) for (int i=(int)(n)-1; (i)>=(int)(m); --(i))
#define all(x) (x).begin(), (x).end()

const int INF = (int)(1e9);

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	if (n >= 16) {
		cout << ((1<<16)-1) << endl;
		return 0;
	}
	unordered_set<int> st;
	st.insert(0);
	rep(i, n) {
		int val = a[i];
		unordered_set<int> nst;
		rep(j, 16) {
			for (const int& pval : st) nst.insert(pval|val);
			val = ((val&1)<<15) + (val >> 1);
		}
		swap(nst, st);
	}
	int res = 0;
	for (const int& pval : st) res = max(res, pval);
	cout << res << endl;
	return 0;
}
0