結果

問題 No.698 ペアでチームを作ろう
ユーザー kakeyamay
提出日時 2019-07-02 07:55:21
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 7 ms / 1,000 ms
コード長 413 bytes
コンパイル時間 2,540 ms
コンパイル使用メモリ 195,764 KB
最終ジャッジ日時 2025-01-07 05:49:58
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int main() {
	
	int N;
	std::cin >> N;
	std::vector<int> A(N);
	for(auto&v:A)std::cin >> v;
	
	std::vector<int> dp(1<<N,0);
	
	for(int x=0;x<(1<<N);++x){
		for(int a=0;a<N;++a){
			for(int b=a+1;b<N;++b){
				if(x&(1<<a))continue;
				if(x&(1<<b))continue;
				int v=x|(1<<a)|(1<<b);
				dp[v]=std::max(dp[v],dp[x]+(A[a]^A[b]));
			}
		}
	}
	std::cout << dp[(1<<N)-1] << std::endl;
}
0