結果
問題 |
No.698 ペアでチームを作ろう
|
ユーザー |
![]() |
提出日時 | 2018-10-15 05:18:44 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 1,000 ms |
コード長 | 477 bytes |
コンパイル時間 | 2,058 ms |
コンパイル使用メモリ | 194,056 KB |
最終ジャッジ日時 | 2025-01-06 14:33:00 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
#include<bits/stdc++.h> typedef long long ll; using namespace std; const ll MOD = 1e9+7; const ll MAX= 1000001; int main(){ int n; cin>>n; int a[n+1]; int dp[1<<15]; for(int i=0; i<n; i++){ cin>>a[i]; } for(int mask=0; mask<(1<<n); mask++){ for(int i=0; i<n; i++){ for(int j=i+1; j<n; j++){ if(mask&(1<<i)||mask&(1<<j)){ continue; } dp[mask+(1<<i)+(1<<j)]=max(dp[mask+(1<<i)+(1<<j)],dp[mask]+(a[i]^a[j])); } } } cout<<dp[(1<<n)-1]<<endl; }