結果

問題 No.698 ペアでチームを作ろう
ユーザー momoyuu
提出日時 2023-03-24 03:13:51
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 520 bytes
コンパイル時間 2,972 ms
コンパイル使用メモリ 249,124 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-18 15:50:08
合計ジャッジ時間 5,193 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 2 RE * 1
other WA * 1 RE * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i = 0;i<n;i++) cin>>a[i];
    vector<ll> dp(1<<n,0);
    for(int i = 0;i<1<<n;i++){
        for(int j = 0;j<n;j++) if(~i>>j&1) {
            for(int k = j + 1;k<n;k++) if(~i>>k&1) {
                assert(j!=k);
                int nxt = i  +  1<<j + 1<<k;
                dp[nxt] = max(dp[nxt],dp[i]+(ll)a[j]^a[k]);
            }
        }
    }
    cout<<dp[(int)(1<<n)-1]<<endl;
}
0