結果

問題 No.699 ペアでチームを作ろう2
ユーザー gazelle
提出日時 2018-06-12 22:07:55
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 235 ms / 1,000 ms
コード長 1,328 bytes
コンパイル時間 3,388 ms
コンパイル使用メモリ 122,364 KB
最終ジャッジ日時 2025-01-05 13:03:03
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-7
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

void solve() {

}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	vector<ll> a(n);
	REP(i,n) cin>>a[i];
	ll ans=0;
	REP(bit,(1ll<<n)) {
		bitset<14> bi(bit);
		if(bi.count()!=n/2) continue;
		vector<ll> g1;
		vector<ll> g2;
		REP(i,n) {
			if(bi[i]) g1.pb(a[i]);
			else g2.pb(a[i]);
		}
		vector<ll> perm(n/2);
		REP(i,n/2) perm[i]=i;
		ll sum=0;
		do {
			ll buf=0;
			REP(i,n/2) {
				buf^=g1[i]+g2[perm[i]];
			}
			sum=max(buf,sum);
		} while(next_permutation(ALL(perm)));
		ans=max(ans,sum);
	}
	cout<<ans<<endl;
}
0