結果

問題 No.698 ペアでチームを作ろう
ユーザー dsaito11dsaito11
提出日時 2019-07-26 13:19:12
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 10 ms / 1,000 ms
コード長 902 bytes
コンパイル時間 1,314 ms
コンパイル使用メモリ 86,724 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-15 00:18:56
合計ジャッジ時間 2,609 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

//#include <bits/stdc++.h>

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>

#define INF 100000000
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;
int main() {
   int n;
   cin >> n;

   vector<int> a(n);
   int i, j, k;
   for(i = 0; i < n; i++){
       cin >> a[i];
   }

   int dp[1<<n];
   for(i = 0; i < (1<<n); i++){
       dp[i] = 0;
   }

   for(i = 0; i < (1<<n); i++){
       for(j = 0; j < n; j++){
           for(k = 0; k < n; k++){
               if((i>>j)%2 == 0 && (i>>k)%2 == 0){
                   int nexti = i | (1<<j) | (1<<k);
                   int nextd = dp[i] + (a[j] ^ a[k]);
                   dp[nexti] = max(dp[nexti], nextd);
               }
           }
       }
   }

   cout << dp[(1<<n)-1] << endl;
}




0