結果

問題 No.698 ペアでチームを作ろう
ユーザー eQeeQe
提出日時 2018-09-19 15:44:17
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,320 bytes
コンパイル時間 569 ms
コンパイル使用メモリ 73,588 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-25 10:09:46
合計ジャッジ時間 1,732 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 5 ms
4,380 KB
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 <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