結果

問題 No.699 ペアでチームを作ろう2
ユーザー mamumamura1mamumamura1
提出日時 2018-06-15 14:14:27
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 678 bytes
コンパイル時間 1,190 ms
コンパイル使用メモリ 145,248 KB
実行使用メモリ 8,752 KB
最終ジャッジ日時 2023-09-13 04:36:01
合計ジャッジ時間 4,961 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

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;
int n;
vector<ll>vll(50);
ll memo[60000]={};
ll dfs(int used,ll sum,ll ma){
  if(memo[used]>ma)return memo[used];
  memo[used]=ma;
  if(used==((1<<n)-1)){
    return ma=max(ma,sum);
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if((used&(1<<i))||(used&(1<<j)))
	continue;
      ma=max(dfs((used+(1<<i)+(1<<j)),sum^(vll[i]+vll[j]),ma),ma);
    }
  }
  return ma;
}
int main(){
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>vll[i];
  cout<<dfs(0,0,0)<<endl;
  return 0;
}
0