結果

問題 No.698 ペアでチームを作ろう
ユーザー mamumamura1mamumamura1
提出日時 2018-06-29 14:05:40
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 5 ms / 1,000 ms
コード長 863 bytes
コンパイル時間 1,675 ms
コンパイル使用メモリ 146,476 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-13 15:09:10
合計ジャッジ時間 2,666 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;

void bits (int a,int fix){
  string s="";
  while(a>0){
    char c='0'+a%2;
    a/=2;
    s+=c;
  }
  for(int i=s.size();i<fix;i++)
    s+='0';
  reverse(s.begin(),s.end());
  cout<<s<<endl;
}


int main(){
  int n;cin>>n;
  int dp[1<<15]={};
  int A[15]={};
  for(int i=0;i<n;i++)cin>>A[i];
  for(int i=0;i<(1<<n);i++){
    for(int j=0;j<n;j++){
      if(!(((i)&(1<<j))==0))continue;
      for(int k=j+1;k<n;k++){
	if(!(((i)&(1<<k))==0))continue;
	dp[i+(1<<j)+(1<<k)] = max(dp[i+(1<<j)+(1<<k)],dp[i]+(A[j]^A[k]));
      }
    }
  }
  // for(int i=0;i<(1<<(n));i++){
  //   bits(i,n);
  //   cout<<dp[i]<<endl<<endl;
  // }
  cout<<dp[(1<<n)-1]<<endl;
  return 0;
}
0