結果

問題 No.90 品物の並び替え
ユーザー RCCWRCCW
提出日時 2017-03-02 22:25:37
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 437 ms / 5,000 ms
コード長 579 bytes
コンパイル時間 1,212 ms
コンパイル使用メモリ 147,048 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-03 21:02:38
合計ジャッジ時間 2,525 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
int n,m;

int main(){
cin>>n>>m;
int box[m][n];
int ans=0;
int maxv=0;
for (int i = 0; i < m; ++i) {
	for (int j = 0; j < 3; ++j) {
		cin>>box[i][j];
	}
}

std::vector<int> data;
for(int i=0; i<n; ++i){
  data.push_back(i);
}
// 全ての順列を出力
do{
	for (int i = 0; i < m; ++i) {
		for (int k = 0; k < n; ++k) {
				if(data[k]==box[i][0]){
					ans=ans+box[i][2];
				}else if(data[k]==box[i][1]){
					break;
				}
			}
	}
	maxv=max(maxv,ans);
ans=0;
}while(next_permutation(data.begin(), data.end()));
cout<<maxv<<endl;
}
0