結果

問題 No.698 ペアでチームを作ろう
ユーザー orange orangeorange orange
提出日時 2023-10-13 01:50:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 1,000 ms
コード長 1,129 bytes
コンパイル時間 856 ms
コンパイル使用メモリ 100,680 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-13 01:50:16
合計ジャッジ時間 1,836 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 3 ms
4,352 KB
testcase_05 AC 6 ms
4,352 KB
testcase_06 AC 6 ms
4,348 KB
testcase_07 AC 6 ms
4,352 KB
testcase_08 AC 6 ms
4,348 KB
testcase_09 AC 6 ms
4,352 KB
testcase_10 AC 6 ms
4,348 KB
testcase_11 AC 7 ms
4,352 KB
testcase_12 AC 6 ms
4,352 KB
testcase_13 AC 6 ms
4,348 KB
testcase_14 AC 7 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<climits>
#include<set>
#include<map>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<assert.h>
#include<numeric>
#include<bitset>

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
using namespace std;
const int inf = INT_MAX / 2;
const ll infl = 1LL << 62;
const double PI = 2 * acos(0.0);
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return a ? gcd(b % a, a) : b; }

int n;
int A[20];
int dp[20000];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> A[i];

	for (int msk = 0; msk < 1 << n; msk++) {
		for (int a = 0; a < n; a++) for (int b = a + 1; b < n; b++) {
			if (!(msk & 1 << a) && !(msk & 1 << b)) {
				chmax(dp[msk + (1 << a) + (1 << b)], dp[msk] + (A[a] ^ A[b]));
			}
		}
	}

	cout << dp[(1 << n) - 1] << endl;
}
0