結果

問題 No.699 ペアでチームを作ろう2
ユーザー treeonetreeone
提出日時 2018-08-02 23:32:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 653 bytes
コンパイル時間 1,517 ms
コンパイル使用メモリ 169,764 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 21:10:34
合計ジャッジ時間 2,636 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
#define chmax(x, y) x = max(x, y)
using namespace std;
typedef pair<int, int> P;
const int INF = 1e15;
int dp[1LL << 14];

signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    for(int mask = 0; mask < (1LL << n); mask++){
        rep(i, 0, n){
            rep(j, i + 1, n){
                if(!(mask & (1LL << i)) && !(mask &(1LL << j))){
                    chmax(dp[mask + (1LL << i) + (1LL << j)], dp[mask] + (a[i]^a[j]));
                }
            }
        }
    }
    cout << dp[(1LL << n) - 1] << endl;
}
0