結果
| 問題 |
No.1246 ANDORゲーム(max)
|
| コンテスト | |
| ユーザー |
momoyuu
|
| 提出日時 | 2023-09-24 02:55:48 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 438 ms / 2,000 ms |
| コード長 | 640 bytes |
| コンパイル時間 | 3,145 ms |
| コンパイル使用メモリ | 254,424 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-17 03:01:10 |
| 合計ジャッジ時間 | 10,058 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n,t;
cin>>n>>t;
map<ll,ll> dp;
dp[t] = 0;
for(int i = 0;i<n;i++){
int a;
cin>>a;
map<ll,ll> ndp;
for(auto&itr:dp){
int nxt = itr.first & a;
ndp[nxt] = max(ndp[nxt],itr.second+abs(nxt-itr.first));
nxt = itr.first | a;
ndp[nxt] = max(ndp[nxt],itr.second+abs(nxt-itr.first));
}
swap(ndp,dp);
}
ll ans = 0;
for(auto&itr:dp) ans = max(ans,itr.second);
cout<<ans<<endl;
}
momoyuu