結果
問題 | No.2071 Shift and OR |
ユーザー |
|
提出日時 | 2022-09-16 21:49:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 49 ms / 2,000 ms |
コード長 | 893 bytes |
コンパイル時間 | 1,861 ms |
コンパイル使用メモリ | 197,588 KB |
最終ジャッジ日時 | 2025-02-07 09:20:28 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 |
ソースコード
#include <bits/stdc++.h>using namespace std;#ifdef _RUTHEN#include <debug.hpp>#else#define show(...) true#endifusing ll = long long;#define rep(i, n) for (int i = 0; i < (n); i++)template <class T> using V = vector<T>;int main() {ios::sync_with_stdio(false);cin.tie(0);int N;cin >> N;V<int> A(N);rep(i, N) cin >> A[i];int M = 1 << 16;V<int> dp(M);dp[0] = 1;rep(i, N) {V<int> np = dp;rep(j, M) {if (dp[j]) {rep(k, 16) {np[j | A[i]] = 1;A[i] = (A[i] >> 1) + (1 << 15) * (A[i] & 1);}}}swap(dp, np);if (dp[M - 1]) {cout << M - 1 << '\n';return 0;}}int ans = 0;rep(i, M) ans = max(ans, i * dp[i]);cout << ans << '\n';return 0;}