結果
| 問題 |
No.90 品物の並び替え
|
| コンテスト | |
| ユーザー |
ninoinui
|
| 提出日時 | 2020-09-26 06:32:15 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 477 ms / 5,000 ms |
| コード長 | 854 bytes |
| コンパイル時間 | 1,819 ms |
| コンパイル使用メモリ | 200,596 KB |
| 最終ジャッジ日時 | 2025-01-14 21:56:55 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U> void cmin(T &a, U b) {
if (a > b) a = b;
}
template <typename T, typename U> void cmax(T &a, U b) {
if (a < b) a = b;
}
signed main() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
long N, M;
cin >> N >> M;
vector<tuple<long, long, long>> V(M);
for (long i = 0; i < M; i++) {
long a, b, c;
cin >> a >> b >> c;
V.at(i) = {a, b, c};
}
vector<long> A(N);
iota(A.begin(), A.end(), 0);
long ans = 0;
do {
long tmp = 0;
for (long i = 0; i < M; i++) {
auto [a, b, c] = V.at(i);
long x = find(A.begin(), A.end(), a) - A.begin();
long y = find(A.begin(), A.end(), b) - A.begin();
if (x < y) tmp += c;
}
cmax(ans, tmp);
} while (next_permutation(A.begin(), A.end()));
cout << ans << "\n";
}
ninoinui