結果
| 問題 |
No.698 ペアでチームを作ろう
|
| ユーザー |
treeone
|
| 提出日時 | 2018-08-02 23:32:11 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 1,000 ms |
| コード長 | 653 bytes |
| コンパイル時間 | 1,353 ms |
| コンパイル使用メモリ | 169,676 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-19 17:14:31 |
| 合計ジャッジ時間 | 1,966 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
#define chmax(x, y) x = max(x, y)
using namespace std;
typedef pair<int, int> P;
const int INF = 1e15;
int dp[1LL << 14];
signed main(){
int n;
cin >> n;
vector<int> a(n);
rep(i, 0, n) cin >> a[i];
for(int mask = 0; mask < (1LL << n); mask++){
rep(i, 0, n){
rep(j, i + 1, n){
if(!(mask & (1LL << i)) && !(mask &(1LL << j))){
chmax(dp[mask + (1LL << i) + (1LL << j)], dp[mask] + (a[i]^a[j]));
}
}
}
}
cout << dp[(1LL << n) - 1] << endl;
}
treeone