結果
問題 |
No.699 ペアでチームを作ろう2
|
ユーザー |
![]() |
提出日時 | 2018-06-15 14:08:44 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 676 bytes |
コンパイル時間 | 1,373 ms |
コンパイル使用メモリ | 161,412 KB |
実行使用メモリ | 13,888 KB |
最終ジャッジ日時 | 2024-06-30 14:47:46 |
合計ジャッジ時間 | 5,313 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 1 TLE * 2 -- * 9 |
ソースコード
#include<bits/stdc++.h> #define INF 1e9 #define llINF 1e18 #define MOD 1e9+7 #define pb push_back #define mp make_pair #define F first #define S second #define ll long long using namespace std; int n; vector<ll>vll(50); ll memo[50][50]={}; ll dfs(int used,ll sum,ll ma){ if(used==((1<<n)-1)){ return ma=max(ma,sum); } for(int i=0;i<n;i++){ for(int j=i+1;j<n;j++){ if((i==j)||(used&(1<<i))||(used&(1<<j))) continue; if(memo[i][j]>ma)continue; memo[i][j]=ma=max(dfs((used+(1<<i)+(1<<j)),sum^(vll[i]+vll[j]),ma),ma); } } return ma; } int main(){ cin>>n; for(int i=0;i<n;i++) cin>>vll[i]; cout<<dfs(0,0,0)<<endl; return 0; }