結果
| 問題 | No.698 ペアでチームを作ろう |
| ユーザー |
ama_nuko
|
| 提出日時 | 2018-06-25 00:36:10 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 1,000 ms |
| コード長 | 977 bytes |
| 記録 | |
| コンパイル時間 | 844 ms |
| コンパイル使用メモリ | 98,220 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-30 22:37:54 |
| 合計ジャッジ時間 | 1,514 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>
#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef pair<int, int> P;
const int INF = 1e15;
const int MOD = 1e9+7;
signed main(){
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
vector<int> dp(1 << n);
dp[0] = 0;
rep(s, (1 << n)){
vector<int> x;
rep(i, n){
if((s >> i) % 2 == 1){
x.push_back(i);
}
}
if(x.size() % 2 == 1){
continue;
}
rep(i, (int)x.size()){
for(int j = i+1; j < (int)x.size(); j++){
int ss = s ^ (1 << x[i]) ^ (1 << x[j]);
dp[s] = max(dp[s], dp[ss] + (a[x[i]] ^ a[x[j]]));
}
}
}
cout << dp[(1 << n) - 1] << endl;
return 0;
}
ama_nuko