結果
問題 | No.1246 ANDORゲーム(max) |
ユーザー |
![]() |
提出日時 | 2020-08-05 12:22:30 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 464 ms / 2,000 ms |
コード長 | 691 bytes |
コンパイル時間 | 2,216 ms |
コンパイル使用メモリ | 201,292 KB |
最終ジャッジ日時 | 2025-01-12 14:43:22 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
ソースコード
#include<bits/stdc++.h> using namespace std; #define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i ) #define rep(i,n) REP(i,0,n) using ll = long long; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin>>n; int t; cin>>t; map<int,ll> dp; dp[t]=0; rep(i,n){ int x; cin>>x; map<int,ll> ndp; for(auto e:dp){ ndp[e.first|x] = max(ndp[e.first|x],e.second + (e.first|x) - e.first); ndp[e.first&x] = max(ndp[e.first&x],e.second + e.first - (e.first&x)); } dp.swap(ndp); } ll ma=0; for(auto e:dp)ma=max(e.second, ma); cout<<ma<<endl; return 0; }