結果
問題 |
No.698 ペアでチームを作ろう
|
ユーザー |
![]() |
提出日時 | 2019-04-05 16:25:04 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 5 ms / 1,000 ms |
コード長 | 663 bytes |
コンパイル時間 | 724 ms |
コンパイル使用メモリ | 83,044 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-11 19:18:45 |
合計ジャッジ時間 | 1,213 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
#include <algorithm> #include <iostream> #include <iomanip> #include <cstring> #include <string> #include <vector> #include <queue> #include <cmath> #include <stack> #include <set> #include <map> typedef long long ll; using namespace std; int main(){ int N; cin >> N; int a[N]; for(int i=0;i<N;i++) cin >> a[i]; int dp[1<<N]; fill(dp,dp+(1<<N),0); for(int i=0;i<(1<<N);i++){ for(int j=0;j<N;j++){ for(int k=j+1;k<N;k++){ if(!(i & (1 << j)) && !(i & (1 << k))){ dp[i + (1<<j) + (1<<k)] = max(dp[i + (1<<j) + (1<<k)], dp[i] + (a[j] ^ a[k])); } } } } cout << dp[(1 << N) - 1] << endl; return 0; }