結果

問題 No.698 ペアでチームを作ろう
ユーザー Yasunari0414Yasunari0414
提出日時 2021-12-06 23:06:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 1,000 ms
コード長 902 bytes
コンパイル時間 6,002 ms
コンパイル使用メモリ 284,492 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-21 15:59:06
合計ジャッジ時間 7,215 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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