結果

問題 No.519 アイドルユニット
ユーザー yukudoyukudo
提出日時 2017-05-28 23:36:05
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 881 ms / 1,000 ms
コード長 843 bytes
コンパイル時間 1,546 ms
コンパイル使用メモリ 159,612 KB
実行使用メモリ 69,052 KB
最終ジャッジ日時 2024-04-14 06:35:11
合計ジャッジ時間 9,424 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 770 ms
68,996 KB
testcase_01 AC 846 ms
68,948 KB
testcase_02 AC 217 ms
68,960 KB
testcase_03 AC 30 ms
69,036 KB
testcase_04 AC 20 ms
68,872 KB
testcase_05 AC 20 ms
68,992 KB
testcase_06 AC 19 ms
68,960 KB
testcase_07 AC 19 ms
69,036 KB
testcase_08 AC 19 ms
68,952 KB
testcase_09 AC 20 ms
68,896 KB
testcase_10 AC 21 ms
68,740 KB
testcase_11 AC 30 ms
68,976 KB
testcase_12 AC 19 ms
69,000 KB
testcase_13 AC 30 ms
68,936 KB
testcase_14 AC 30 ms
68,908 KB
testcase_15 AC 31 ms
68,948 KB
testcase_16 AC 30 ms
68,960 KB
testcase_17 AC 31 ms
68,836 KB
testcase_18 AC 30 ms
68,920 KB
testcase_19 AC 31 ms
68,900 KB
testcase_20 AC 43 ms
68,984 KB
testcase_21 AC 31 ms
68,996 KB
testcase_22 AC 31 ms
69,032 KB
testcase_23 AC 31 ms
68,900 KB
testcase_24 AC 63 ms
68,832 KB
testcase_25 AC 65 ms
68,904 KB
testcase_26 AC 62 ms
68,948 KB
testcase_27 AC 64 ms
68,972 KB
testcase_28 AC 62 ms
68,904 KB
testcase_29 AC 830 ms
69,052 KB
testcase_30 AC 824 ms
68,960 KB
testcase_31 AC 818 ms
68,976 KB
testcase_32 AC 881 ms
68,924 KB
testcase_33 AC 19 ms
68,868 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, 0, sizeof(dp));
  int N; cin >> N;
  REP(i, N) REP(j, N) cin >> F[i][j];

  REP(set, 1 << N) {
    if(__builtin_popcount(set) % 2 == 1) continue;
    int a = 0;
    REP(i, N) if ((set >> i & 1) == 0) {
      a = i;
      break;
    }
    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