結果
問題 |
No.698 ペアでチームを作ろう
|
ユーザー |
![]() |
提出日時 | 2019-09-26 14:18:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 1,000 ms |
コード長 | 1,118 bytes |
コンパイル時間 | 772 ms |
コンパイル使用メモリ | 95,916 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-23 07:46:32 |
合計ジャッジ時間 | 1,469 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
#include <cstdio> #include <cstdlib> #include <algorithm> #include <vector> #include <cstring> #include <queue> #include <set> #include <unordered_set> #include <unordered_map> #include <map> #include <functional> #include <cmath> #include <cassert> #include <string> #include <iostream> using namespace std; typedef long long ll; typedef pair<int, int> P; //typedef pair<ll, ll> P; ll MOD = 1000000007; //ll INF = 1LL << 60; template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill((T *)array, (T *)(array + N), val); } int a[15], dp[1 << 15]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for(int i=0; i < n; i++) cin >> a[i]; for(int i=0; i < (1 << n); i++){ for(int p=0; p < n; p++){ for(int q=p+1; q < n; q++){ if (!(i & (1 << p)) && !(i & (1 << q)))//集合iがpとqを除いた集合だった場合 { dp[i + (1 << p) + (1 << q)] = max(dp[i + (1 << p) + (1 << q)], dp[i] + (a[p] ^ a[q])); } } } } cout << dp[(1 << n) - 1] << endl; }