結果

問題 No.698 ペアでチームを作ろう
ユーザー kakeyamaykakeyamay
提出日時 2019-07-02 07:55:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 1,000 ms
コード長 413 bytes
コンパイル時間 2,032 ms
コンパイル使用メモリ 200,112 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-26 12:29:14
合計ジャッジ時間 2,862 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 6 ms
4,376 KB
testcase_06 AC 7 ms
4,380 KB
testcase_07 AC 7 ms
4,376 KB
testcase_08 AC 7 ms
4,376 KB
testcase_09 AC 7 ms
4,380 KB
testcase_10 AC 7 ms
4,376 KB
testcase_11 AC 6 ms
4,376 KB
testcase_12 AC 6 ms
4,380 KB
testcase_13 AC 6 ms
4,376 KB
testcase_14 AC 6 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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