結果

問題 No.699 ペアでチームを作ろう2
ユーザー chocoruskchocorusk
提出日時 2018-09-20 06:04:19
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 19 ms / 1,000 ms
コード長 845 bytes
コンパイル時間 1,919 ms
コンパイル使用メモリ 72,452 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 10:24:38
合計ジャッジ時間 1,685 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int d[7];
ll ans;
int n;
ll a[14];
void solve(int i){
  if(i==n/2){
    bool used[14]={};
    int x=0;
    ll ans1=0;
    for(int j=0; j<n/2; j++){
      while(used[x]) x++;
      int y=x, c=0;
      while(c<d[j]){
        y++;
        if(!used[y]){
          c++;
        }
      }
      ans1^=(a[x]+a[y]);
      used[x]=1;
      used[y]=1;
    }
    ans=max(ans, ans1);
    return;
  }
  for(int j=1; j<=n-2*i-1; j++){
    d[i]=j;
    solve(i+1);
  }
}

int main()
{
  cin>>n;
  for(int i=0; i<n; i++) cin>>a[i];
  solve(0);
  cout<<ans<<endl;
	return 0;
}
0