結果
問題 | No.90 品物の並び替え |
ユーザー |
|
提出日時 | 2020-04-12 04:17:38 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 81 ms / 5,000 ms |
コード長 | 842 bytes |
コンパイル時間 | 771 ms |
コンパイル使用メモリ | 81,832 KB |
最終ジャッジ日時 | 2025-01-09 17:36:35 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
#include <iostream> #include <algorithm> #include <numeric> #include <vector> #include <tuple> void solve() { int n, m; std::cin >> n >> m; std::vector<std::tuple<int, int, int>> ts(m); for (auto& t : ts) { int x, y, c; std::cin >> x >> y >> c; t = std::make_tuple(x, y, c); } std::vector<int> idxs(n); std::iota(idxs.begin(), idxs.end(), 0); int ans = 0; do { int score = 0; for (auto t : ts) { int x, y, c; std::tie(x, y, c) = t; if (idxs[x] < idxs[y]) score += c; } ans = std::max(ans, score); } while (std::next_permutation(idxs.begin(), idxs.end())); std::cout << ans << std::endl; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }