結果

問題 No.519 アイドルユニット
ユーザー imulanimulan
提出日時 2017-06-02 02:14:07
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 35 ms / 1,000 ms
コード長 690 bytes
コンパイル時間 1,656 ms
コンパイル使用メモリ 163,900 KB
実行使用メモリ 69,268 KB
最終ジャッジ日時 2024-04-14 06:43:15
合計ジャッジ時間 3,460 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
69,140 KB
testcase_01 AC 35 ms
69,032 KB
testcase_02 AC 25 ms
69,064 KB
testcase_03 AC 21 ms
69,040 KB
testcase_04 AC 19 ms
69,096 KB
testcase_05 AC 19 ms
69,112 KB
testcase_06 AC 20 ms
69,152 KB
testcase_07 AC 20 ms
69,088 KB
testcase_08 AC 20 ms
69,168 KB
testcase_09 AC 20 ms
69,132 KB
testcase_10 AC 20 ms
68,992 KB
testcase_11 AC 20 ms
69,024 KB
testcase_12 AC 20 ms
69,096 KB
testcase_13 AC 21 ms
69,076 KB
testcase_14 AC 20 ms
69,132 KB
testcase_15 AC 20 ms
69,104 KB
testcase_16 AC 20 ms
68,980 KB
testcase_17 AC 20 ms
69,124 KB
testcase_18 AC 20 ms
69,048 KB
testcase_19 AC 20 ms
68,960 KB
testcase_20 AC 20 ms
69,088 KB
testcase_21 AC 20 ms
68,960 KB
testcase_22 AC 20 ms
69,048 KB
testcase_23 AC 21 ms
69,012 KB
testcase_24 AC 21 ms
69,004 KB
testcase_25 AC 21 ms
69,004 KB
testcase_26 AC 21 ms
69,268 KB
testcase_27 AC 22 ms
69,096 KB
testcase_28 AC 21 ms
68,956 KB
testcase_29 AC 33 ms
69,124 KB
testcase_30 AC 35 ms
69,064 KB
testcase_31 AC 34 ms
69,068 KB
testcase_32 AC 35 ms
69,072 KB
testcase_33 AC 20 ms
69,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int n;
int f[24][24];

const int N=1<<24;
int dp[N];
int dfs(int s)
{
    if(s == (1<<n)-1) return 0;
    if(dp[s]>=0) return dp[s];

    int ret=0;

    int i=0;
    while(s>>i&1) ++i;

    for(int j=i+1; j<n; ++j)if(!(s>>j&1))
    {
        int ns = s|(1<<i)|(1<<j);
        ret = max(ret,dfs(ns)+f[i][j]);
    }

    return dp[s]=ret;
}

int main()
{
    cin >>n;
    rep(i,n)rep(j,n) cin >>f[i][j];
    memset(dp,-1,sizeof(dp));
    cout << dfs(0) << endl;
    return 0;
}
0