結果
| 問題 | No.698 ペアでチームを作ろう |
| ユーザー |
|
| 提出日時 | 2018-08-12 22:29:55 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 1,000 ms |
| コード長 | 733 bytes |
| 記録 | |
| コンパイル時間 | 1,554 ms |
| コンパイル使用メモリ | 170,060 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-24 07:36:27 |
| 合計ジャッジ時間 | 2,198 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int dfs(int used, int n_rem, int score, const vector<int>& As){
if (n_rem == 0) return score;
int record = score;
for (int i = 0; i < As.size() - 1; ++i){
if (used & (1 << i)) continue;
for (int j = i + 1; j < As.size(); ++j){
if (used & (1 << j)) continue;
int new_used = used | (1 << i) | (1 << j);
int new_score = score + (As[i] ^ As[j]);
record = max(record, dfs(new_used, n_rem - 2, new_score, As));
}
break;
}
return record;
}
int main() {
int N;
cin >> N;
vector<int> As(N);
for (auto & a : As) cin >> a;
cout << dfs(0, N, 0, As) << endl;
return 0;
}