結果

問題 No.519 アイドルユニット
ユーザー どららどらら
提出日時 2017-05-29 00:12:53
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 70 ms / 1,000 ms
コード長 754 bytes
コンパイル時間 1,643 ms
コンパイル使用メモリ 163,936 KB
実行使用メモリ 134,772 KB
最終ジャッジ日時 2024-04-14 06:37:04
合計ジャッジ時間 4,464 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
134,756 KB
testcase_01 AC 69 ms
134,772 KB
testcase_02 AC 47 ms
134,628 KB
testcase_03 AC 38 ms
134,640 KB
testcase_04 AC 38 ms
134,620 KB
testcase_05 AC 38 ms
134,568 KB
testcase_06 AC 39 ms
134,644 KB
testcase_07 AC 37 ms
134,584 KB
testcase_08 AC 38 ms
134,732 KB
testcase_09 AC 37 ms
134,588 KB
testcase_10 AC 37 ms
134,548 KB
testcase_11 AC 37 ms
134,608 KB
testcase_12 AC 38 ms
134,616 KB
testcase_13 AC 38 ms
134,672 KB
testcase_14 AC 38 ms
134,600 KB
testcase_15 AC 38 ms
134,652 KB
testcase_16 AC 40 ms
134,640 KB
testcase_17 AC 38 ms
134,716 KB
testcase_18 AC 38 ms
134,672 KB
testcase_19 AC 38 ms
134,628 KB
testcase_20 AC 40 ms
134,540 KB
testcase_21 AC 40 ms
134,756 KB
testcase_22 AC 40 ms
134,704 KB
testcase_23 AC 39 ms
134,612 KB
testcase_24 AC 39 ms
134,704 KB
testcase_25 AC 39 ms
134,632 KB
testcase_26 AC 40 ms
134,648 KB
testcase_27 AC 40 ms
134,680 KB
testcase_28 AC 40 ms
134,540 KB
testcase_29 AC 70 ms
134,600 KB
testcase_30 AC 70 ms
134,636 KB
testcase_31 AC 69 ms
134,528 KB
testcase_32 AC 69 ms
134,536 KB
testcase_33 AC 38 ms
134,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int N;
int cost[30][30];

int dp[1<<25];


int main(){
  cin >> N;
  rep(i,N){
    rep(j,N){
      cin >> cost[i][j];
    }
  }

  rep(i,1<<25) dp[i] = -1;
  dp[0] = 0;

  rep(i,1<<N){
    if(dp[i] < 0) continue;

    rep(j,N) if(((i>>j)&1) == 0){
      REP(k,j+1,N) if(((i>>k)&1) == 0){
        int ii = i | (1<<j) | (1<<k);
        dp[ii] = max(dp[ii], cost[j][k] + dp[i]);
      }
      break;
    }
  }
  cout << dp[(1<<N)-1] << endl;
  return 0;
}
0