結果

問題 No.698 ペアでチームを作ろう
ユーザー kkktymkkktym
提出日時 2019-09-25 19:07:31
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 7 ms / 1,000 ms
コード長 503 bytes
コンパイル時間 468 ms
コンパイル使用メモリ 62,224 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-23 18:56:40
合計ジャッジ時間 1,556 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  vector<int> dp(1<<n);
  rep(S,1<<n){
    for(int i=0;i<n;++i){
      for(int j=i+1;j<n;++j){
	if((!(S&(1<<i)))&&(!(S&(1<<j)))){
	  dp[S|(1<<i)|(1<<j)] = max(dp[S|(1<<i)|(1<<j)],dp[S]+(a[i]^a[j]));
	}
      }
    }
  }
  cout << dp[(1<<n)-1] << "\n";
  return 0;
}
0