結果
問題 |
No.699 ペアでチームを作ろう2
|
ユーザー |
|
提出日時 | 2020-08-02 16:07:11 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 1,000 ms |
コード長 | 755 bytes |
コンパイル時間 | 838 ms |
コンパイル使用メモリ | 86,312 KB |
最終ジャッジ日時 | 2025-01-12 13:25:19 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
#include <iostream> #include <vector> #include <functional> void solve() { int n; std::cin >> n; std::vector<int> xs(n); for (auto& x : xs) std::cin >> x; std::function<int(int, int)> dfs = [&](int b, int s) -> int { int i = 0; while ((b >> i) & 1) ++i; if (i == n) return s; int ret = 0; for (int j = i + 1; j < n; ++j) { if ((b >> j) & 1) continue; int ns = s ^ (xs[i] + xs[j]); int nb = b | (1 << i) | (1 << j); ret = std::max(ret, dfs(nb, ns)); } return ret; }; std::cout << dfs(0, 0) << "\n"; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }