結果

問題 No.2071 Shift and OR
ユーザー norikamenorikame
提出日時 2022-09-17 00:53:20
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 229 ms / 2,000 ms
コード長 886 bytes
コンパイル時間 4,338 ms
コンパイル使用メモリ 263,832 KB
実行使用メモリ 8,268 KB
最終ジャッジ日時 2023-08-23 17:18:28
合計ジャッジ時間 8,555 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 9 ms
4,376 KB
testcase_03 AC 70 ms
6,460 KB
testcase_04 AC 31 ms
6,436 KB
testcase_05 AC 135 ms
6,376 KB
testcase_06 AC 43 ms
6,700 KB
testcase_07 AC 15 ms
4,924 KB
testcase_08 AC 24 ms
5,300 KB
testcase_09 AC 34 ms
6,612 KB
testcase_10 AC 42 ms
6,852 KB
testcase_11 AC 147 ms
7,388 KB
testcase_12 AC 149 ms
8,228 KB
testcase_13 AC 125 ms
7,388 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 92 ms
7,488 KB
testcase_16 AC 89 ms
7,480 KB
testcase_17 AC 147 ms
7,028 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 193 ms
8,268 KB
testcase_20 AC 163 ms
6,152 KB
testcase_21 AC 229 ms
6,248 KB
testcase_22 AC 214 ms
6,652 KB
testcase_23 AC 49 ms
4,376 KB
testcase_24 AC 7 ms
4,376 KB
testcase_25 AC 24 ms
4,380 KB
testcase_26 AC 28 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 53 ms
4,376 KB
testcase_29 AC 53 ms
4,376 KB
testcase_30 AC 77 ms
8,012 KB
testcase_31 AC 31 ms
5,784 KB
testcase_32 AC 33 ms
6,544 KB
testcase_33 AC 39 ms
6,872 KB
testcase_34 AC 50 ms
6,840 KB
testcase_35 AC 55 ms
7,668 KB
testcase_36 AC 74 ms
7,948 KB
testcase_37 AC 46 ms
6,864 KB
testcase_38 AC 40 ms
6,932 KB
testcase_39 AC 34 ms
6,712 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