結果
問題 |
No.699 ペアでチームを作ろう2
|
ユーザー |
|
提出日時 | 2018-09-04 13:52:37 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 1,000 ms |
コード長 | 600 bytes |
コンパイル時間 | 569 ms |
コンパイル使用メモリ | 65,336 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-13 08:59:17 |
合計ジャッジ時間 | 1,146 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
#include<iostream> using namespace std; int n, ans = 0, a[14] = {}; int dfs(int score, int bitset){ if(bitset == (1<<n)-1){ return score; } int ret = 0; for(int i = 0; i < n; i++){ if(bitset & 1<<i) continue; for(int j = i+1; j < n; j++){ if(~bitset & 1<<j){ int nbitset = bitset^1<<i^1<<j; ret = max(ret, dfs(score ^ (a[i] + a[j]), nbitset)); } } break; } return ret; } int main(){ cin >> n; for(int i = 0; i < n; i++) cin >> a[i]; cout << dfs(0,0) << endl; }