結果

問題 No.699 ペアでチームを作ろう2
ユーザー chocorusk
提出日時 2018-09-20 06:04:19
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 16 ms / 1,000 ms
コード長 845 bytes
コンパイル時間 1,037 ms
コンパイル使用メモリ 79,096 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-18 08:27:12
合計ジャッジ時間 1,361 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

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