結果

問題 No.698 ペアでチームを作ろう
ユーザー ohreitetsuohreitetsu
提出日時 2018-11-28 22:22:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 418 ms / 1,000 ms
コード長 500 bytes
コンパイル時間 631 ms
コンパイル使用メモリ 74,956 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-09 05:50:12
合計ジャッジ時間 4,895 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(int argc, char* argv[])
{
	int N;
	cin>>N;
	vector<int> A(N);
	int i;
	for (i=0;i<N;i++){
		cin>>A[i];
	}
	sort(A.begin(),A.end());
	int Max=0;
	do {
		int s=0;
		for (i=0;i<N/2;i++){
			s+=A[i]^A[i+N/2];
		}
		Max=max(s,Max);
		reverse(A.begin()+N/2,A.end());
		s=0;
		for (i=0;i<N/2;i++){
			s+=A[i]^A[i+N/2];
		}
		Max=max(s,Max);
	}while(next_permutation(A.begin(),A.end()));
	cout<<Max<<endl;
	return 0;
}
0