結果

問題 No.698 ペアでチームを作ろう
ユーザー eQeeQe
提出日時 2018-09-19 15:53:09
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 6 ms / 1,000 ms
コード長 1,286 bytes
コンパイル時間 641 ms
コンパイル使用メモリ 73,396 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-25 10:10:08
合計ジャッジ時間 1,646 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl;
#define pno cout << "no" << endl;
#define pYe cout << "Yes" << endl;
#define pNo cout << "No" << endl;
#define pYE cout << "YES" << endl;
#define pNO cout << "NO" << endl;
#define prin(num) cout << num << endl;
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 100000000000
#define MOD 1000000007LL
#define MAX_V 10005
#define MAX_E 30005
#define NIL -1
#define WHITE 0
#define BLACK 1
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

int main(void) {
    ll N, i;
    cin >> N;
    ll A[14];
    ll dp[1<<14]={0};
    ll msk;
    ll a, b;
    
    for(i=0; i<N; i++) {
        cin >> A[i];
    }
    
    for(msk=0; msk<1<<N; msk++) {
        for(a=0; a<N; a++) {
            for(b=a+1; b<N; b++) {
                if(!(msk>>a&1) && !(msk>>b&1)) {
                    dp[msk+(1<<a)+(1<<b)]=max(dp[msk+(1<<a)+(1<<b)], dp[msk]+(A[a]^A[b]));
                }
            }
        }
    }
    
    prin(dp[(1<<N)-1]);
}
0