結果
問題 | No.90 品物の並び替え |
ユーザー |
|
提出日時 | 2015-02-26 20:19:33 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 15 ms / 5,000 ms |
コード長 | 660 bytes |
コンパイル時間 | 624 ms |
コンパイル使用メモリ | 66,972 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-23 23:50:53 |
合計ジャッジ時間 | 1,370 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
#include <iostream>#include <cstdio>#include <vector>#include <algorithm>#include <utility>using namespace std;int main() {int n, m;int a, b, c;cin >> n >> m;vector< vector<int> > score(n, vector<int>(n, 0));for (int i = 0; i < m; i++) {cin >> a >> b >> c;score[a][b] = c;}vector<int> order(n, 0);for (int i = 0; i < n; i++) {order[i] = i;}int ans = 0;int total;do {total = 0;for (int i = 0; i < n; i++) {for (int j = i + 1; j < n; j++) {total += score[order[i]][order[j]];}}ans = max(ans, total);} while (next_permutation(order.begin(), order.end()));cout << ans << endl;return 0;}