結果
| 問題 | No.2071 Shift and OR |
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2022-09-18 01:25:18 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 24 ms / 2,000 ms |
| コード長 | 956 bytes |
| 記録 | |
| コンパイル時間 | 282 ms |
| コンパイル使用メモリ | 42,304 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-22 01:04:31 |
| 合計ジャッジ時間 | 1,738 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 2071.cc: No.2071 Shift and OR - yukicoder
*/
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 200000;
const int K = 16;
const int KBITS = 1 << K;
/* typedef */
/* global variables */
int as[MAX_N];
bool dp[K][KBITS];
/* subroutines */
inline int shift(int x, int l) {
return ((x >> l) | (x << (K - l))) & (KBITS - 1);
}
/* main */
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", as + i);
int m = 0;
for (int i = 0; i < n; i++)
if (as[i] > 0) as[m++] = as[i];
if (m >= K) { printf("%d\n", KBITS - 1); return 0; }
dp[0][0] = true;
for (int i = 0; i < m; i++)
for (int j = 0; j < KBITS; j++)
if (dp[i][j]) {
for (int l = 0; l < K; l++) {
int x = shift(as[i], l);
dp[i + 1][j | x] = true;
}
}
for (int x = KBITS - 1; x >= 0; x--)
if (dp[m][x]) { printf("%d\n", x); break; }
return 0;
}
tnakao0123