結果

問題 No.519 アイドルユニット
ユーザー gigimegigime
提出日時 2017-05-28 23:42:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 804 bytes
コンパイル時間 1,626 ms
コンパイル使用メモリ 167,540 KB
実行使用メモリ 69,352 KB
最終ジャッジ日時 2023-10-21 14:46:44
合計ジャッジ時間 13,405 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 AC 323 ms
20,872 KB
testcase_03 AC 22 ms
6,536 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 3 ms
4,348 KB
testcase_10 AC 7 ms
4,348 KB
testcase_11 AC 21 ms
6,536 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 21 ms
6,536 KB
testcase_14 AC 21 ms
6,536 KB
testcase_15 AC 21 ms
6,536 KB
testcase_16 AC 21 ms
6,536 KB
testcase_17 AC 21 ms
6,536 KB
testcase_18 AC 22 ms
6,536 KB
testcase_19 AC 21 ms
6,536 KB
testcase_20 AC 22 ms
6,536 KB
testcase_21 AC 21 ms
6,536 KB
testcase_22 AC 21 ms
6,536 KB
testcase_23 AC 21 ms
6,536 KB
testcase_24 AC 82 ms
8,584 KB
testcase_25 AC 82 ms
8,584 KB
testcase_26 AC 81 ms
8,584 KB
testcase_27 AC 83 ms
8,584 KB
testcase_28 AC 81 ms
8,584 KB
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N;
const int MAX_N = 24;
int edge [MAX_N] [MAX_N];
int dp [1 << MAX_N];
const int INF = 1e9;

int main()
{
	scanf("%d",&N);
	FOR(i,0,N) FOR(j,0,N){
		scanf("%d",&edge [i] [j]);
	}

	fill(dp,dp + (1 << N),-INF);
	dp [0] = 0;
	FOR(mask,0,1 << N){
		FOR(i,0,N) if((mask >> i & 1) == 0){
			FOR(j,i + 1,N) if((mask >> j & 1) == 0){
				int nmask = mask | (1 << i) | (1 << j);
				chmax(dp [nmask],dp [mask] + edge [i] [j]);
			}
			break;
		}
	}

	printf("%d\n",dp [(1 << N) - 1]);

	return 0;
}
0