結果

問題 No.699 ペアでチームを作ろう2
ユーザー gazellegazelle
提出日時 2018-06-12 22:07:55
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 142 ms / 1,000 ms
コード長 1,328 bytes
コンパイル時間 1,260 ms
コンパイル使用メモリ 126,976 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-13 03:42:38
合計ジャッジ時間 3,478 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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