結果

問題 No.699 ペアでチームを作ろう2
ユーザー t98slidert98slider
提出日時 2022-12-20 16:01:00
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 1,000 ms
コード長 529 bytes
コンパイル時間 1,718 ms
コンパイル使用メモリ 167,248 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-11 10:19:34
合計ジャッジ時間 2,712 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 9 ms
4,380 KB
testcase_06 AC 8 ms
4,380 KB
testcase_07 AC 8 ms
4,384 KB
testcase_08 AC 8 ms
4,380 KB
testcase_09 AC 9 ms
4,384 KB
testcase_10 AC 8 ms
4,384 KB
testcase_11 AC 8 ms
4,384 KB
testcase_12 AC 8 ms
4,380 KB
testcase_13 AC 9 ms
4,384 KB
testcase_14 AC 9 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(auto &&v:a)cin >> v;
  function<int(int,int)> dfs = [&](int S, int v){
    if(__builtin_popcount(S) == n)return v;
    int ans = 0;
    for(int i = 0; i < n; i++){
      if(S >> i & 1)continue;
      S |= 1 << i;
      for(int j = i + 1; j < n; j++){
        if(S >> j & 1)continue;
        ans = max(ans, dfs(S | (1 << j), v ^ (a[i] + a[j])));
      }
      break;
    }
    return ans;
  };
  cout << dfs(0, 0) << '\n';
}
0