結果
| 問題 | No.698 ペアでチームを作ろう |
| ユーザー |
|
| 提出日時 | 2020-04-17 01:04:58 |
| 言語 | C++14 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 15 ms / 1,000 ms |
| + 100µs | |
| コード長 | 570 bytes |
| 記録 | |
| コンパイル時間 | 863 ms |
| コンパイル使用メモリ | 179,992 KB |
| 実行使用メモリ | 6,528 KB |
| 最終ジャッジ日時 | 2026-09-09 11:17:41 |
| 合計ジャッジ時間 | 2,188 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}