結果

問題 No.90 品物の並び替え
ユーザー shimomireshimomire
提出日時 2014-12-07 19:17:50
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 93 ms / 5,000 ms
コード長 1,456 bytes
コンパイル時間 862 ms
コンパイル使用メモリ 111,996 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-02 09:19:04
合計ジャッジ時間 1,646 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <ctime>
#include <iostream>// io
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>// container
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <algorithm>// other
#include <utility>
#include <complex>
#include <numeric>
#include <functional>
#include <random>
#include <regex>

using namespace std;
typedef long long ll;

#define ALL(c) (c).begin(),(c).end()
#define FOR(i,l,r) for(int i=(int)l;i<(int)r;++i)
#define REP(i,n) FOR(i,0,n)
#define FORr(i,l,r) for(int i=(int)r-1;i>=(int)l;--i)
#define REPr(i,n) FORr(i,0,n)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end())
//debug
#define DUMP(x)  cerr << #x << " = " << (x)
#define LINE()    cerr<< " (L" << __LINE__ << ")"

template<typename T,typename U> T pmod(T x,U M){return (x%M+M)%M;}

stringstream ss;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	ss   <<fixed <<setprecision(20);
	cout <<fixed <<setprecision(20);

	int N,M;cin >> N >> M;
	vector<int> item1(M),item2(M),score(M);
	REP(i,M)cin >> item1[i] >> item2[i] >> score[i];

	vector<int> per(N);iota(ALL(per),0);
	ll Mv=0;
	do{
		ll v=0;
		REP(i,M)if(per[item1[i]]<per[item2[i]])v+=score[i];
		Mv=max(Mv,v);
	}while(next_permutation(ALL(per)));
	cout << Mv <<endl;

 	return 0;
 }
0