結果

問題 No.2071 Shift and OR
コンテスト
ユーザー Hydrogen332
提出日時 2025-10-20 00:58:13
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 680 bytes
コンパイル時間 2,980 ms
コンパイル使用メモリ 283,788 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-10-20 00:58:18
合計ジャッジ時間 4,785 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (int i = (int)(s); i < (int)(e); ++i)

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	
	int N;
	cin >> N;
	
	if (N >= 16) {
		cout << (1 << 16) - 1 << '\n';
		return 0;
	}
	
	vector<int> A(N);
	rep(i, 0, N) cin >> A[i];
	
	vector dp(N + 1, vector<bool>(1 << 16, false));
	dp[0][0] = true;
	
	rep(i, 0, N) {
		rep(j, 0, 1 << 16) if (dp[i][j]) {
			rep(t, 0, 16) {
				dp[i + 1][j | A[i]] = true;
				A[i] = (A[i] >> 1) + ((A[i] & 1) << 15);
			}
		}
	}
	
	for (int bit = (1 << 16) - 1; bit >= 0; --bit) {
		if (dp[N][bit]) {
			cout << bit << '\n';
			break;
		}
	}
}
0