結果

問題 No.90 品物の並び替え
ユーザー dnishdnish
提出日時 2017-07-04 23:37:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 15 ms / 5,000 ms
コード長 454 bytes
コンパイル時間 1,624 ms
コンパイル使用メモリ 164,992 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 16:21:54
合計ジャッジ時間 2,133 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int) N;i++)
#define p(s) cout<<(s)<<endl
using namespace std;

int item[10][10];

int main(){
	int N,M;
	cin>>N>>M;
	REP(i,0,M){
		int a,b;
		cin>>a>>b;
		cin>>item[a][b];
	}
	vector<int> v(N);
	REP(i,0,N) v[i]=i;
	int ans=0;
	do{
		int mx=0;
		REP(j,1,N){
			REP(i,0,j){
				mx+=item[v[i]][v[j]];
			}
		}
		ans=max(ans,mx);
	}while(next_permutation(v.begin(),v.end()));
	p(ans);
	return 0;
}
0