結果
| 問題 |
No.1246 ANDORゲーム(max)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-02 22:12:20 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 505 ms / 2,000 ms |
| コード長 | 439 bytes |
| コンパイル時間 | 744 ms |
| コンパイル使用メモリ | 81,044 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-17 21:25:21 |
| 合計ジャッジ時間 | 7,898 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 |
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
7 | main()
| ^~~~
ソースコード
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int N,T;
map<int,long>mp;
main()
{
cin>>N>>T;
mp[T]=0;
for(;N--;)
{
int A;cin>>A;
map<int,long>nxt;
for(pair<int,long>p:mp)
{
int q=p.first&A;
nxt[q]=max(nxt[q],p.second+abs(p.first-q));
q=p.first|A;
nxt[q]=max(nxt[q],p.second+abs(p.first-q));
}
mp=nxt;
}
long ans=0;
for(pair<int,long>p:mp)ans=max(ans,p.second);
cout<<ans<<endl;
}