結果
| 問題 | No.698 ペアでチームを作ろう |
| ユーザー |
|
| 提出日時 | 2020-04-17 01:04:58 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 18 ms / 1,000 ms |
| コード長 | 570 bytes |
| 記録 | |
| コンパイル時間 | 1,299 ms |
| コンパイル使用メモリ | 166,824 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-03 05:45:34 |
| 合計ジャッジ時間 | 1,970 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int dp[1<<14];
int A[14];
void dfs(int bit)
{
for(int i = 0;i<n;i++)
{
for(int j = i+1;j<n;j++)
{
if(((bit&(1<<i))==0)&&((bit&(1<<j))==0))
{
//cout<<';'<<endl;
if(dp[bit]+(A[i]^A[j])>dp[bit+(1<<i)+(1<<j)])
{
dp[bit+(1<<i)+(1<<j)] = dp[bit] + (A[i]^A[j]);
dfs(bit+(1<<i)+(1<<j));
}
}
}
}
}
int main()
{
cin >> n;
for(int i = 0 ;i<n;i++)cin >> A[i];
dfs(0);
//for(int i = 0; i<(1<<n);i++)cout<<dp[i]<<endl;
cout<<dp[(1<<n)-1]<<endl;
return 0;
}