結果

問題 No.90 品物の並び替え
ユーザー newlife171128newlife171128
提出日時 2017-12-23 23:04:42
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 607 bytes
コンパイル時間 546 ms
コンパイル使用メモリ 68,588 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-09 22:26:52
合計ジャッジ時間 1,132 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>

using namespace std;

int n;
int item[10][10];

int main() {

	cin>>n;

	vector<int> nums;

	int m;
	cin>>m;

	for(int i=0; i<n;i++){
		nums.push_back(i);
	}
	int Item1,Item2,score;
	for(int i=0; i<m;i++){
		cin>>Item1>>Item2>>score;

		item[Item1][Item2] =score;
	}
	int ans=0;
	int tmp=0;
	do {
		for(int i=0; i<nums.size()-1;i++){
			tmp += item[nums[i]][nums[i+1]];
		}

		ans = max(ans,tmp);
		tmp=0;;

	} while (next_permutation(nums.begin(),nums.end()));

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