結果
問題 | No.90 品物の並び替え |
ユーザー |
|
提出日時 | 2015-04-21 12:51:31 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 13 ms / 5,000 ms |
コード長 | 709 bytes |
コンパイル時間 | 606 ms |
コンパイル使用メモリ | 66,692 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-04 19:07:11 |
合計ジャッジ時間 | 1,164 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
#include <iostream>#include <algorithm>#include <vector>using namespace std;int main(){int N, M;cin >> N >> M;vector<vector<int>>data;vector<int>data2;data.resize(N);data2.resize(N);for (size_t i = 0; i < N; i++){data[i].resize(N);for (size_t j = 0; j < N; j++){data[i][j] = 0;}data2[i] = i;}int a, b, c;for (size_t i = 0; i < M; i++){cin >> a >> b >> c;data[a][b] = c;}int ans = 0;do{int max_ = 0;for (size_t i = 0; i < N-1; i++){for (size_t j = i+1; j < N; j++){max_ += data[data2[i]][data2[j]];}}ans = max(ans, max_);} while (next_permutation(data2.begin(), data2.end()));cout << ans << endl;return 0;}