結果
問題 |
No.698 ペアでチームを作ろう
|
ユーザー |
![]() |
提出日時 | 2019-02-21 19:17:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 1,000 ms |
コード長 | 912 bytes |
コンパイル時間 | 919 ms |
コンパイル使用メモリ | 89,264 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-19 13:40:19 |
合計ジャッジ時間 | 1,667 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
#include<iostream> #include<cstdio> #include<cstring> #include <cstdlib> #include <cmath> #include<cctype> #include<string> #include<set> #include <map> #include<algorithm> #include <functional> #include<vector> #include<climits> #include<stack> #include<queue> #include <deque> #include <typeinfo> #include <utility> #define all(x) (x).begin(),(x).end() #define rep(i,m,n) for(int i = m;i < n;++i) using namespace std; using ll = long long; using R = double; const ll inf = 1LL << 50; const ll MOD = 1e9 + 7; int n, A[14], dp[1 << 14]; void chmax(int &a,int b) { if (a == -1)a = b; else if (a < b)a = b; } int main() { cin >> n; rep(i, 0, n)cin >> A[i]; memset(dp, -1, sizeof(dp)); dp[0] = 0; rep(msk, 0, 1 << n)rep(a, 0, n - 1)rep(b, a + 1, n)if (!(msk&(1<<a)) && !(msk&(1<<b)) && dp[msk]>=0) { chmax(dp[msk+(1<<a)+(1<<b)],dp[msk]+(A[a]^A[b])); } cout << dp[(1<<n)-1] << endl; return 0; }