結果
問題 | No.90 品物の並び替え |
ユーザー |
|
提出日時 | 2017-04-02 23:51:22 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 12 ms / 5,000 ms |
コード長 | 783 bytes |
コンパイル時間 | 864 ms |
コンパイル使用メモリ | 86,320 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-08 00:20:13 |
合計ジャッジ時間 | 1,291 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
#define _USE_MATH_DEFINES#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<string>#include<iostream>#include<cctype>#include<cstdio>#include<vector>#include<stack>#include<queue>#include <algorithm>#include<math.h>#include<set>#include<map>#include<iomanip>//#include<bits/stdc++.h>using namespace std;int main() {int n, m;cin >> n >> m;vector<int>p(n);for (int i = 0; i < n; i++)p[i] = i;vector<vector<int>>Q(n, vector<int>(n));for (int i = 0; i < m; i++) {int a, b, c;cin >> a >> b >> c;Q[a][b] = c;}int ans = 0;do{int t = 0;for (int i = 0; i < n; i++)for (int j = i + 1; j < n; j++)t += Q[p[i]][p[j]];ans = max(ans, t);} while (next_permutation(begin(p), end(p)));cout << ans << endl;return 0;}