結果
| 問題 | 
                            No.90 品物の並び替え
                             | 
                    
| コンテスト | |
| ユーザー | 
                             yuma220284
                         | 
                    
| 提出日時 | 2019-08-10 12:36:11 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 83 ms / 5,000 ms | 
| コード長 | 618 bytes | 
| コンパイル時間 | 1,476 ms | 
| コンパイル使用メモリ | 163,076 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-19 17:05:57 | 
| 合計ジャッジ時間 | 1,908 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 9 | 
ソースコード
#include "bits/stdc++.h"
using namespace std;
struct item {
	int before;
	int after;
	long long score;
};
int main() {
	int N, M;
	long long ANS = 0;
	vector<int> V;
	item X[100];
	cin >> N >> M;
	for (int i = 0; i < N; i++) V.push_back(i);
	for (int i = 0; i < M; i++) {
		cin >> X[i].before >> X[i].after >> X[i].score;
	}
	do {
		int Y[9] = {};
		for (int i = 0; i < N; i++) {
			Y[V[i]] = i;
		}
		long long COUNT = 0;
		for (int i = 0; i < M; i++) {
			if (Y[X[i].before] < Y[X[i].after]) COUNT += X[i].score;
		}
		ANS = max(ANS, COUNT);
	} while (next_permutation(V.begin(), V.end()));
	cout << ANS << endl;
}
            
            
            
        
            
yuma220284