結果

問題 No.90 品物の並び替え
ユーザー silopysilopy
提出日時 2019-06-28 23:32:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 108 ms / 5,000 ms
コード長 511 bytes
コンパイル時間 522 ms
コンパイル使用メモリ 66,912 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 22:45:48
合計ジャッジ時間 1,287 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 9 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 11 ms
4,380 KB
testcase_06 AC 7 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 108 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
using lint=int64_t;

int main()
{
	int N,M;
	int item1[110];
	int item2[110];
	int score[110];

	cin >> N >> M;
	for(int i=0;i<M;i++)
	{
		cin >> item1[i];
		cin >> item2[i];
		cin >> score[i];
	}

	int perm[]={0,1,2,3,4,5,6,7,8,9};
	int ans=0;
	do
	{
		int tans=0;
		for(int i=0;i<M;i++)
		{
			if(perm[item1[i]]<perm[item2[i]])
				tans+=score[i];
		}
		ans=max(ans,tans);
	}while(next_permutation(perm,perm+N));

	cout << ans << endl;
	return 0;
}
0