結果

問題 No.519 アイドルユニット
ユーザー FF256grhyFF256grhy
提出日時 2017-06-18 13:29:33
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 94 ms / 1,000 ms
コード長 694 bytes
コンパイル時間 1,408 ms
コンパイル使用メモリ 159,704 KB
実行使用メモリ 65,280 KB
最終ジャッジ日時 2024-04-10 11:38:30
合計ジャッジ時間 3,161 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
65,152 KB
testcase_01 AC 93 ms
65,280 KB
testcase_02 AC 25 ms
19,456 KB
testcase_03 AC 4 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 3 ms
6,944 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 4 ms
6,944 KB
testcase_14 AC 3 ms
6,940 KB
testcase_15 AC 4 ms
6,944 KB
testcase_16 AC 4 ms
6,940 KB
testcase_17 AC 3 ms
6,944 KB
testcase_18 AC 3 ms
6,940 KB
testcase_19 AC 3 ms
6,944 KB
testcase_20 AC 3 ms
6,940 KB
testcase_21 AC 4 ms
6,944 KB
testcase_22 AC 3 ms
6,940 KB
testcase_23 AC 3 ms
6,940 KB
testcase_24 AC 8 ms
7,296 KB
testcase_25 AC 7 ms
7,424 KB
testcase_26 AC 8 ms
7,424 KB
testcase_27 AC 7 ms
7,296 KB
testcase_28 AC 8 ms
7,424 KB
testcase_29 AC 91 ms
65,152 KB
testcase_30 AC 94 ms
65,152 KB
testcase_31 AC 91 ms
65,152 KB
testcase_32 AC 92 ms
65,280 KB
testcase_33 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define incID(i, l, r) for(int i = (l); i < (r); i++)
#define inc(i, n) incID(i, 0, n)

template<typename T> bool setmax(T & a, T b) { if(b > a) { a = b; return true; } else { return false; } }

// ---- ----

int n, f[24][24];
int dp[1 << 24];

int main() {
	cin >> n;
	inc(i, n) {
	inc(j, n) {
		cin >> f[i][j];
	}
	}
	
	dp[0] = 1;
	inc(i, 1 << n) {
		if(dp[i] == 0) { continue; }
		int j = n;
		inc(jj, n) {
			if(i & (1 << jj)) { continue; }
			j = jj;
			break;
		}
		incID(k, j + 1, n) {
			if(i & (1 << k)) { continue; }
			setmax(dp[i | (1 << j) | (1 << k)], dp[i] + f[j][k]);
		}
	}
	
	cout << dp[(1 << n) - 1] - 1 << endl;
	
	return 0;
}
0