結果

問題 No.90 品物の並び替え
ユーザー NaruYNaruY
提出日時 2018-05-08 14:30:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 703 ms / 5,000 ms
コード長 1,182 bytes
コンパイル時間 1,904 ms
コンパイル使用メモリ 172,044 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-10 11:04:04
合計ジャッジ時間 3,392 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);i++)
#define FORq(i, m, n) for(int i = (m);i <= (n);i++)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////
int main(){
	int N,M; SCD2(N,M);
	vector< vector<int> >score;
	vector<int>per;
	int ans = 0;
	
	REP(i,M){
		int a,b,c; SCD3(a,b,c);
		vector<int> x;
		x.PB(a); x.PB(b); x.PB(c);
		score.PB(x);
	}
	
	REP(i,N){
		per.PB(i);
	}
	
	do{
		int nans = 0;
		REP(i,M){
			vector<int> X = score[i];
			int a = X[0];
			int b = X[1];
			int c = X[2];
			
			if (per[a] < per[b]) nans += c;
		}
		ans = max(nans,ans);
	}while(next_permutation(per.begin(),per.end()));
	
	PRINTD(ans);
	return 0;
}
0