結果

問題 No.698 ペアでチームを作ろう
ユーザー hashiryohashiryo
提出日時 2019-06-06 14:58:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 1,000 ms
コード長 727 bytes
コンパイル時間 1,504 ms
コンパイル使用メモリ 167,524 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-26 01:02:08
合計ジャッジ時間 2,093 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>

#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;cin>>N;
  ll A[20];
  for(ll i=0;i<N;i++)cin>>A[i];
  ll dp[1<<15]={};
  for(ll S=0;S<1<<N;S++){
    for(ll i=0;i<N;i++)if(!((S>>i)&1)){
      for(ll j=i+1;j<N;j++)if(!((S>>j)&1)){
        dp[S|(1<<i)|(1<<j)] = max(dp[S|(1<<i)|(1<<j)],dp[S]+(A[i]^A[j]));
      }
    }
  }
  cout<<dp[(1<<N)-1]<<endl;
  return 0;
}
0