結果

問題 No.90 品物の並び替え
ユーザー koyumeishikoyumeishi
提出日時 2014-12-07 20:34:24
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 793 bytes
コンパイル時間 852 ms
コンパイル使用メモリ 77,200 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-02 09:47:12
合計ジャッジ時間 8,011 ms
ジャッジサーバーID
(参考情報)
judge16 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

void dfs(){
	
}

int main(){
	int n, m;
	cin >> n >> m;

	vector<pair<int,int> > item(m);
	vector<int> score(m);
	for(int i=0; i<m; i++){
		int x,y,z;
		cin >> x >> y >> z;
		item[i] = make_pair(x,y);
		score[i] = z;
	}

	vector<int> v(m);
	//商品iの位置
	for(int i=0; i<m; i++) v[i] = i;

	long long ans = 0;
	do{
		long long tmp = 0;
		for(int i=0; i<m; i++){
			if( v[ item[i].first ] < v[ item[i].second ] ){
				tmp += score[i];
			}
		}
		ans = max(ans, tmp);
		
	}while( next_permutation( v.begin(), v.end() ) );

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