結果
| 問題 |
No.90 品物の並び替え
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-03-31 15:44:56 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 198 ms / 5,000 ms |
| コード長 | 846 bytes |
| コンパイル時間 | 1,483 ms |
| コンパイル使用メモリ | 163,840 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-21 17:56:18 |
| 合計ジャッジ時間 | 2,249 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
typedef long long ll;
typedef pair<int, int> P;
typedef struct{
int first;
int second;
int score;
}T;
//昇順
bool comp_score_greater(T& l, T& r){
return l.score > r.score;
}
int N,M;
vector<T> v;
int calc_score(vector<int> s){
int i,j;
int score=0;
REP(i,v.size()){
REP(j,N){
if(v[i].second == s[j]) break;
if(v[i].first == s[j]){
score += v[i].score;
break;
}
}
}
return score;
}
int main(void){
cin >> N >> M;
v.resize(M);
int i,max = 0;
REP(i,M)cin >> v[i].first >> v[i].second >> v[i].score;
vector<int> s(N);
REP(i,N) s[i] = i;
do{
int score = calc_score(s);
if(max < score) max = score;
}while(next_permutation(s.begin(), s.end()));
cout << max << endl;
return 0;
}