結果

問題 No.698 ペアでチームを作ろう
ユーザー CleyLCleyL
提出日時 2022-05-05 23:43:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 34 ms / 1,000 ms
コード長 698 bytes
コンパイル時間 1,099 ms
コンパイル使用メモリ 77,420 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-18 09:33:07
合計ジャッジ時間 2,584 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int dp[10][(1<<14)+20];
int main(){
	int n;cin>>n;
	vector<int> A(n);
	for(int i = 0; n > i; i++){
		cin>>A[i];
	}
  for(int i = 0; n/2 > i; i++){
    for(int j = 0; (1<<n) > j; j++){
      for(int k = 0; n > k; k++){
        for(int l = k+1; n > l; l++){
          if(!(j & (1<<k)) && !(j & (1<<l))){
            dp[i+1][j+(1<<k)+(1<<l)] = max(dp[i+1][j+(1<<k)+(1<<l)],dp[i][j] + (A[k]^A[l]));
          }
        }
      }
    }
  }
  // for(int i = 0; n/2 >= i; i++){
  //   for(int j = 0; (1<<n) > j; j++){
  //     cout << dp[i][j] << " \n"[j+1 == (1<<n)];
  //   }
  // }
  cout << dp[n/2][(1<<n)-1] << endl;
	
}
0