結果

問題 No.90 品物の並び替え
ユーザー RokiRoki
提出日時 2017-03-14 13:22:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 597 bytes
コンパイル時間 640 ms
コンパイル使用メモリ 75,316 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-12 12:20:33
合計ジャッジ時間 1,420 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>

int main()
{
	std::size_t n{},m{}; 
	std::cin>>n>>m;

	std::vector<std::size_t> v(n);
	std::iota(v.begin(),v.end(),0);

	std::vector<std::vector<std::size_t>> sc(n,std::vector<std::size_t>(n));
	for(std::size_t i{}; i<m; ++i){
		std::size_t l{},r{},sc_{}; 
		std::cin>>l>>r>>sc_;
		sc[l][r]=sc_;
	}

	std::size_t rs{};
	do{
		std::size_t rs_{};
		for(std::size_t i{}; i<n; ++i)for(std::size_t j=i+1; j<n; ++j)rs_+=sc[v[i]][v[j]];
		rs=std::max(rs,rs_);
	}while(std::next_permutation(v.begin(),v.end()));

	std::cout<<rs;
}
0