結果

問題 No.519 アイドルユニット
ユーザー yukudoyukudo
提出日時 2017-05-29 11:25:55
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 47 ms / 1,000 ms
コード長 772 bytes
コンパイル時間 1,351 ms
コンパイル使用メモリ 158,724 KB
実行使用メモリ 69,064 KB
最終ジャッジ日時 2024-04-14 06:37:56
合計ジャッジ時間 3,609 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
69,012 KB
testcase_01 AC 47 ms
68,828 KB
testcase_02 AC 28 ms
68,972 KB
testcase_03 AC 20 ms
68,980 KB
testcase_04 AC 20 ms
68,980 KB
testcase_05 AC 19 ms
68,844 KB
testcase_06 AC 20 ms
68,912 KB
testcase_07 AC 20 ms
68,880 KB
testcase_08 AC 20 ms
68,848 KB
testcase_09 AC 19 ms
68,916 KB
testcase_10 AC 20 ms
68,848 KB
testcase_11 AC 20 ms
68,824 KB
testcase_12 AC 20 ms
68,984 KB
testcase_13 AC 20 ms
68,752 KB
testcase_14 AC 20 ms
68,952 KB
testcase_15 AC 20 ms
68,988 KB
testcase_16 AC 20 ms
68,720 KB
testcase_17 AC 21 ms
68,952 KB
testcase_18 AC 21 ms
68,944 KB
testcase_19 AC 20 ms
68,820 KB
testcase_20 AC 20 ms
69,000 KB
testcase_21 AC 20 ms
68,944 KB
testcase_22 AC 20 ms
68,760 KB
testcase_23 AC 21 ms
68,992 KB
testcase_24 AC 22 ms
68,956 KB
testcase_25 AC 22 ms
68,860 KB
testcase_26 AC 22 ms
68,816 KB
testcase_27 AC 22 ms
68,716 KB
testcase_28 AC 22 ms
68,996 KB
testcase_29 AC 46 ms
69,064 KB
testcase_30 AC 45 ms
69,000 KB
testcase_31 AC 46 ms
68,848 KB
testcase_32 AC 46 ms
68,776 KB
testcase_33 AC 19 ms
68,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for (int i=0,_n=(int)(n); i < _n; i++)
template<class T> bool chkmin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool chkmax(T &a, T b) { return a < b ? (a = b, true) : false; }

typedef long long ll;

int dp[1 << 24];
int F[24][24];

int main2() {
  memset(dp, -1, sizeof(dp));
  int N; cin >> N;
  REP(i, N) REP(j, N) cin >> F[i][j];
  dp[0] = 0;
  REP(set, 1 << N) if (dp[set] >= 0) {
    int a = __builtin_ffs(~set) - 1;
    for (int j = a + 1; j < N; j++) if ((set >> j & 1) == 0) {
      chkmax(dp[set | (1 << a) | (1 << j)], dp[set] + F[a][j]);
    }
  }

  cout << dp[ (1 << N) - 1 ] << endl;

  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}
0