結果
| 問題 | No.90 品物の並び替え |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-12-31 20:16:08 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 74 ms / 5,000 ms |
| コード長 | 1,014 bytes |
| コンパイル時間 | 646 ms |
| コンパイル使用メモリ | 73,244 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-13 04:42:38 |
| 合計ジャッジ時間 | 1,395 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <numeric>
//#include <tuple>
#include <cstdio>
using namespace std;
typedef long long ll;
#define rep(i,b) for(ll i=0;i<(b);++i)
#define rep1(i,b) for(ll i=1;i<=(b);++i)
#define vec vector
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;
int N, M;
int item1[80];
int item2[80];
int score[80];
int main() {
cin >> N >> M;
rep(i, M) {
cin >> item1[i] >> item2[i] >> score[i];
}
vector<int> v(N);
iota(v.begin(), v.end(), 0);
int maxval = 0;
int dp[11]; // 数字からindex
do {
int points = 0;
rep(i, N) {
dp[v[i]] = i;
}
rep(i, M) {
if (dp[item1[i]] < dp[item2[i]]) points += score[i];
}
maxval = max({maxval, points});
// for (auto x: v) cout << x << " "; cout << "\n";
} while ( next_permutation(v.begin(), v.end()));
cout << maxval << endl;
}