結果
問題 |
No.699 ペアでチームを作ろう2
|
ユーザー |
![]() |
提出日時 | 2020-01-08 20:12:37 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 186 ms / 1,000 ms |
コード長 | 731 bytes |
コンパイル時間 | 1,796 ms |
コンパイル使用メモリ | 174,764 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-23 03:06:09 |
合計ジャッジ時間 | 4,108 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (n);i++) #define sz(x) int(x.size()) typedef long long ll; typedef pair<int,int> P; int main(){ int n; cin >> n; vector<int> a(n); rep(i,n) cin >> a[i]; int res = 0; for (int bit = 0; bit < (1 << n); bit++) { if (__builtin_popcount(bit) * 2 != n) continue; vector<int> x, y; for (int i = 0; i < n; i++) { if (bit & (1 << i)) x.emplace_back(a[i]); else y.emplace_back(a[i]); } sort(y.begin(), y.end()); do { int tmp = 0; for (int i = 0; i < n/2; i++) tmp ^= x[i] + y[i]; res = max(res, tmp); } while(next_permutation(y.begin(), y.end())); } cout << res << endl; return 0; }