結果

問題 No.519 アイドルユニット
ユーザー myantamyanta
提出日時 2017-05-29 00:15:12
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 630 ms / 1,000 ms
コード長 695 bytes
コンパイル時間 489 ms
コンパイル使用メモリ 45,056 KB
実行使用メモリ 68,276 KB
最終ジャッジ日時 2024-04-14 06:37:15
合計ジャッジ時間 6,073 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 508 ms
68,136 KB
testcase_01 AC 607 ms
68,220 KB
testcase_02 AC 148 ms
19,008 KB
testcase_03 AC 9 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 3 ms
6,940 KB
testcase_11 AC 10 ms
6,944 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 10 ms
6,940 KB
testcase_14 AC 9 ms
6,940 KB
testcase_15 AC 9 ms
6,944 KB
testcase_16 AC 10 ms
6,940 KB
testcase_17 AC 9 ms
6,944 KB
testcase_18 AC 10 ms
6,940 KB
testcase_19 AC 10 ms
6,940 KB
testcase_20 AC 10 ms
6,944 KB
testcase_21 AC 9 ms
6,940 KB
testcase_22 AC 9 ms
6,940 KB
testcase_23 AC 10 ms
6,940 KB
testcase_24 AC 33 ms
6,940 KB
testcase_25 AC 32 ms
6,944 KB
testcase_26 AC 34 ms
6,940 KB
testcase_27 AC 35 ms
6,944 KB
testcase_28 AC 32 ms
6,940 KB
testcase_29 AC 616 ms
68,132 KB
testcase_30 AC 574 ms
68,076 KB
testcase_31 AC 599 ms
68,276 KB
testcase_32 AC 630 ms
68,128 KB
testcase_33 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:57:51: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   57 |                         for(int j=0;j<n;j++) scanf("%d", &f[i][j]);
      |                                              ~~~~~^~~~~~~~~~~~~~~~

ソースコード

diff #

#include<cstdio>
#include<vector>
#include<queue>


using namespace std;

using vi=vector<int>;
using vvi=vector<vi>;


int max_u(int&m, int v)
{
	if(m<v)
	{
		m=v;
		return 1;
	}
	return 0;
}


int solve(vvi& f)
{
	int n=f.size();
	vi score(1<<n, 0);
	int i, j, k, idx;

	for(i=0;i<n;i++)
	{
		for(j=0;j<i;j++)
		{
			idx=(1<<i)|(1<<j);
			for(k=0;k<idx;k++)
			{
				if(k&idx) continue;
				max_u(score[idx|k], score[k]+f[i][j]);
			}
		}
	}

	return score[(1<<n)-1];
}


int main(void)
{
	vvi f;
	int n;

	while(scanf("%d", &n)==1)
	{
		f.resize(n);
		for(int i=0;i<n;i++)
		{
			f[i].resize(n);
			for(int j=0;j<n;j++) scanf("%d", &f[i][j]);
		}
		printf("%d\n", solve(f));
	}

	return 0;
}
0