結果
問題 | No.699 ペアでチームを作ろう2 |
ユーザー |
![]() |
提出日時 | 2019-04-10 14:40:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,560 bytes |
コンパイル時間 | 1,002 ms |
コンパイル使用メモリ | 102,824 KB |
実行使用メモリ | 10,624 KB |
最終ジャッジ日時 | 2024-07-07 05:24:47 |
合計ジャッジ時間 | 4,455 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 1 TLE * 1 -- * 10 |
ソースコード
#include <iostream>#include <vector>#include <list>#include <algorithm>#include <string>#include <sstream>#include <stack>#include <iomanip>#include <numeric>#include <queue>#include <climits>#include <set>#include <complex>#include <cmath>#include <cstring>#include <map>using namespace std;using ll = long long;#define MOD 1000000007#define INF 1LL << 59using ld = long double;int arr[15];int N;int maxV = 0;void dfs(int d, stack<int> st, bool used[15]){if (d == N){int sum = 0;while (st.size()){sum = sum ^ st.top();st.pop();}maxV = max(maxV, sum);return;}for (int i = 0; i < N; ++i){if (!used[i]){used[i] = true;if (d % 2 == 1){int n = st.top();st.pop();st.push(n + arr[i]);dfs(d + 1, st, used);st.pop();st.push(n);}else{st.push(arr[i]);dfs(d + 1, st, used);st.pop();}used[i] = false;}}}int main(){std::ios::sync_with_stdio(false);std::cin.tie(0);//cout << fixed << setprecision(5);cin >> N;for (int i = 0; i < N; ++i)cin >> arr[i];bool used[15];for (int i = 0; i < N; ++i)used[i] = false;stack<int> st;dfs(0, st, used);cout << maxV << endl;return 0;}