結果
問題 | No.90 品物の並び替え |
ユーザー |
|
提出日時 | 2016-12-22 21:04:13 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 16 ms / 5,000 ms |
コード長 | 508 bytes |
コンパイル時間 | 1,686 ms |
コンパイル使用メモリ | 171,268 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-14 14:53:39 |
合計ジャッジ時間 | 2,380 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main() {int n, m;cin >> n >> m;vector<vector<int>> g(n, vector<int>(n));for (int i = 0; i < m; i++) {int a, b, c;cin >> a >> b >> c;g[a][b] = c;}int ans = 0;vector<int> p(n);iota(p.begin(), p.end(), 0);do {int score = 0;for (int i = 0; i < n; i++) {for (int j = i + 1; j < n; j++) {score += g[p[i]][p[j]];}}ans = max(ans, score);} while (next_permutation(p.begin(), p.end()));cout << ans << endl;}