結果

問題 No.519 アイドルユニット
ユーザー yukudoyukudo
提出日時 2017-05-28 22:05:38
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 792 bytes
コンパイル時間 1,492 ms
コンパイル使用メモリ 160,516 KB
実行使用メモリ 69,196 KB
最終ジャッジ日時 2023-10-21 14:13:31
合計ジャッジ時間 14,544 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 AC 368 ms
69,196 KB
testcase_03 AC 38 ms
69,196 KB
testcase_04 AC 18 ms
69,196 KB
testcase_05 AC 18 ms
69,196 KB
testcase_06 AC 18 ms
69,196 KB
testcase_07 AC 18 ms
69,196 KB
testcase_08 AC 19 ms
69,196 KB
testcase_09 AC 19 ms
69,196 KB
testcase_10 AC 23 ms
69,196 KB
testcase_11 AC 39 ms
69,196 KB
testcase_12 AC 18 ms
69,196 KB
testcase_13 AC 37 ms
69,196 KB
testcase_14 AC 38 ms
69,196 KB
testcase_15 AC 38 ms
69,196 KB
testcase_16 AC 40 ms
69,196 KB
testcase_17 AC 37 ms
69,196 KB
testcase_18 AC 38 ms
69,196 KB
testcase_19 AC 38 ms
69,196 KB
testcase_20 AC 37 ms
69,196 KB
testcase_21 AC 38 ms
69,196 KB
testcase_22 AC 37 ms
69,196 KB
testcase_23 AC 37 ms
69,196 KB
testcase_24 AC 101 ms
69,196 KB
testcase_25 AC 102 ms
69,196 KB
testcase_26 AC 103 ms
69,196 KB
testcase_27 AC 102 ms
69,196 KB
testcase_28 AC 103 ms
69,196 KB
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 AC 18 ms
69,196 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) {
    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