結果
問題 | No.519 アイドルユニット |
ユーザー |
![]() |
提出日時 | 2017-06-01 12:50:38 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 518 bytes |
コンパイル時間 | 483 ms |
コンパイル使用メモリ | 62,324 KB |
実行使用メモリ | 79,360 KB |
最終ジャッジ日時 | 2024-09-21 21:38:22 |
合計ジャッジ時間 | 4,958 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | TLE * 1 -- * 33 |
ソースコード
#include <iostream> #include <vector> using namespace std; int main(){ int n; cin>>n; vector<int> dp(1<<n,-1e9); vector<vector<int>> vv(n,vector<int>(n)); for(int i=0; i<n; i++) for(int j=0; j<n; j++) cin>>vv[i][j]; dp[0] = 0; // cout<<"hoge"<<endl; for(int i=0; i<(1<<n); i++){ for(int j=0; j<n; j++){ if(i&(1<<j)) continue; for(int k=j+1; k<n; k++){ if(!(i&(1<<k))){ int p = i | (1<<j) | (1<<k); dp[p] = max(dp[p], dp[i] + vv[j][k]); } } } } cout << dp[(1<<n)-1] << endl; }