結果

問題 No.699 ペアでチームを作ろう2
ユーザー rpy3cpp
提出日時 2018-08-12 22:42:10
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 7 ms / 1,000 ms
コード長 679 bytes
コンパイル時間 1,495 ms
コンパイル使用メモリ 169,200 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-24 07:36:55
合計ジャッジ時間 2,167 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

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


int dfs(int rem, int score, const vector<int>& As){
    if (rem == 0) return score;
    int record = 0;
    for (int i = 0; i < As.size() - 1; ++i){
        if ((rem & (1 << i)) == 0) continue;
        rem ^= (1 << i);
        for (int j = i + 1; j < As.size(); ++j){
            if ((rem & (1 << j)) == 0) continue;
            record = max(record, dfs(rem ^ (1 << j), score ^ (As[i] + As[j]), As));
        }
        break;
    }
    return record;
}


int main() {
    int N;
    cin >> N;
    vector<int> As(N);
    for (auto & a : As) cin >> a;
    int rem = (1 << N) - 1;
    cout << dfs(rem, 0, As) << endl;

    return 0;
}
0