結果

問題 No.698 ペアでチームを作ろう
ユーザー Yasunari0414
提出日時 2021-12-06 23:06:39
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 9 ms / 1,000 ms
コード長 902 bytes
コンパイル時間 5,844 ms
コンパイル使用メモリ 287,404 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-07 09:46:15
合計ジャッジ時間 6,699 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <sstream>
#include<atcoder/all>
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
using namespace atcoder;
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mp make_pair
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
const int inf = 1 << 29;
using P = pair<int,int>;
const ll mod = 1000000007;
vector<int> dx={1,-1,0,0};
vector<int> dy={0,0,1,-1};

int A[14],dp[1<<14];
int main() {
  int N;
  cin>>N;
  rep(i,N) cin>>A[i];
  
  rep(msk,1 << N){
    rep(a,N) rep(b,a) if(!(msk&(1<<a))) if(!(msk&(1<<b))){
      dp[msk+(1<<a)+(1<<b)]=max(dp[msk+(1<<a)+(1<<b)],dp[msk]+(A[a]^A[b]));
    }
  }
  cout<<dp[(1<<N)-1]<<endl;
}
0