結果
| 問題 |
No.2071 Shift and OR
|
| コンテスト | |
| ユーザー |
NAMIDAIRO
|
| 提出日時 | 2022-09-16 21:44:16 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 13 ms / 2,000 ms |
| コード長 | 1,128 bytes |
| コンパイル時間 | 920 ms |
| コンパイル使用メモリ | 105,016 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-21 18:52:12 |
| 合計ジャッジ時間 | 2,292 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <random>
#include <iomanip>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
template<class T>
using vi = vector<T>;
template<class T>
using vii = vector<vi<T>>;
template<class T>
using viii = vector<vii<T>>;
using pii = pair<int, int>;
using tii = tuple<ll, int, int>;
int shift(int n) {
return n / 2 + (1 << 15) * (n & 1);
}
int main()
{
int n;
cin >> n;
int mx = (1 << 16);
if (n >= 16) {
cout << mx - 1 << endl;
return 0;
}
vi<int> a(n);
rep(i, n) cin >> a[i];
vi<int> dp(mx);
dp[0] = 1;
rep(i, n) {
vi<int> prev(mx);
swap(prev, dp);
rep(j, mx) {
if (prev[j]) {
int ta = a[i];
rep(k, 16) {
dp[j | ta] = 1;
ta = shift(ta);
}
}
}
}
for (int i = mx - 1; i >= 0; i--) if (dp[i]) {
cout << i << endl;
return 0;
}
return 0;
}
NAMIDAIRO