結果

問題 No.698 ペアでチームを作ろう
ユーザー KhiromuKhiromu
提出日時 2018-06-09 18:14:17
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 210 ms / 1,000 ms
コード長 1,113 bytes
コンパイル時間 1,470 ms
コンパイル使用メモリ 149,828 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-13 02:16:08
合計ジャッジ時間 4,216 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define p(s) cout<<(s)<<endl
#define F first
#define S second
typedef long long ll;

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

int dy[] = {0,1,0,-1};
int dx[] = {1,0,-1,0};
int dy8[] = {0,1,1,1,0,-1,-1,-1};
int dx8[] = {1,1,0,-1,-1,-1,0,1};

int N;
int A[20];
int ans;
int main(){
    cin>>N;
    REP(i, 0, N) cin>>A[i];

    sort(A, A+N);


    int b[N];
    REP(i,0,N){
        if(i <  N/2) b[i]=0;
        else b[i]=1;
    }
    do{
        vector<int> v1, v2;
        REP(i, 0, N){
            if(b[i]==1){
                v1.push_back(A[i]);
            }
            else{
                v2.push_back(A[i]);
            }
        }
        do{
            int tmp=0;
            REP(i, 0, N/2){
                tmp+=v1[i]^v2[i];
            }
            ans=max(ans, tmp);
        }while (next_permutation(v1.begin(), v1.end()));
    }while(next_permutation(b,b+N));

    cout<<ans<<endl;
    return 0;
}
0