結果
| 問題 | No.1246 ANDORゲーム(max) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-05-01 02:18:02 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 280 ms / 2,000 ms |
| コード長 | 823 bytes |
| 記録 | |
| コンパイル時間 | 637 ms |
| コンパイル使用メモリ | 110,068 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-20 02:44:46 |
| 合計ジャッジ時間 | 5,688 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 |
ソースコード
#include <iostream>
#include <cmath>
#include <map>
using namespace std;
using lint = long long;
void solve() {
int n, t;
cin >> n >> t;
map<lint, lint> dp{{t, 0}};
while (n--) {
lint x;
cin >> x;
map<lint, lint> ndp;
for (auto [t, c] : dp) {
{
auto nt = t & x;
auto nc = c + abs(t - nt);
ndp[nt] = max(ndp[nt], nc);
}
{
auto nt = t | x;
auto nc = c + abs(t - nt);
ndp[nt] = max(ndp[nt], nc);
}
}
swap(dp, ndp);
}
lint ans = 0;
for (auto [t, c] : dp) ans = max(ans, c);
cout << ans << "\n";
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
solve();
return 0;
}