結果

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

テストケース

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

ソースコード

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