結果

問題 No.519 アイドルユニット
ユーザー FF256grhyFF256grhy
提出日時 2017-06-18 13:33:06
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 696 bytes
コンパイル時間 1,086 ms
コンパイル使用メモリ 158,484 KB
実行使用メモリ 68,992 KB
最終ジャッジ日時 2024-04-09 19:40:38
合計ジャッジ時間 13,944 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 AC 349 ms
19,840 KB
testcase_03 AC 22 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 3 ms
6,944 KB
testcase_10 AC 6 ms
6,940 KB
testcase_11 AC 21 ms
6,940 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 21 ms
6,944 KB
testcase_14 AC 22 ms
6,940 KB
testcase_15 AC 22 ms
6,940 KB
testcase_16 AC 22 ms
6,940 KB
testcase_17 AC 22 ms
6,944 KB
testcase_18 AC 23 ms
6,940 KB
testcase_19 AC 22 ms
6,940 KB
testcase_20 AC 22 ms
6,940 KB
testcase_21 AC 22 ms
6,940 KB
testcase_22 AC 21 ms
6,940 KB
testcase_23 AC 21 ms
6,940 KB
testcase_24 AC 86 ms
7,424 KB
testcase_25 AC 88 ms
7,424 KB
testcase_26 AC 88 ms
7,424 KB
testcase_27 AC 87 ms
7,552 KB
testcase_28 AC 86 ms
7,296 KB
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 AC 2 ms
6,944 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