結果
問題 | No.699 ペアでチームを作ろう2 |
ユーザー | otoshigo |
提出日時 | 2023-02-23 13:45:23 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 8 ms / 1,000 ms |
コード長 | 1,011 bytes |
コンパイル時間 | 624 ms |
コンパイル使用メモリ | 73,676 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-30 16:16:30 |
合計ジャッジ時間 | 1,568 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 2 ms
4,376 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 8 ms
4,376 KB |
testcase_06 | AC | 8 ms
4,376 KB |
testcase_07 | AC | 8 ms
4,380 KB |
testcase_08 | AC | 8 ms
4,376 KB |
testcase_09 | AC | 8 ms
4,376 KB |
testcase_10 | AC | 8 ms
4,376 KB |
testcase_11 | AC | 8 ms
4,376 KB |
testcase_12 | AC | 8 ms
4,380 KB |
testcase_13 | AC | 8 ms
4,380 KB |
testcase_14 | AC | 8 ms
4,376 KB |
ソースコード
#include<iostream> #include<vector> using namespace std; using ll=long long; #define rep(i,n) for(int i=0;i<n;i++) #define rrep(i,n) for(int i=(n)-1;i>=0;i--) #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} void dfs(int xr,int &ans,int s,int N,vector<int>&A){ if(s==0)chmax(ans,xr); else{ bool flag=true; int at=-1; rep(i,N){ if(s>>i&1){ if(flag){ at=i; flag=false; }else{ dfs(xr^(A[at]+A[i]),ans,s^(1<<at)^(1<<i),N,A); } } } } } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin>>N; vector<int>A(N); rep(i,N)cin>>A[i]; int ans=0; dfs(0,ans,(1<<N)-1,N,A); cout<<ans<<"\n"; }