結果
問題 | No.90 品物の並び替え |
ユーザー |
![]() |
提出日時 | 2015-06-16 22:14:56 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 11 ms / 5,000 ms |
コード長 | 842 bytes |
コンパイル時間 | 607 ms |
コンパイル使用メモリ | 79,560 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-07 03:23:01 |
合計ジャッジ時間 | 1,191 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
#include <iostream> #include <algorithm> #include <vector> #include <string> #include <cmath> #include <iomanip> #include <map> using namespace std; typedef long long LL; const LL MOD=1000000000; int main(){ LL N, M; cin >> N >> M; vector<vector<int> > val(N, vector<int>(N)); for(int i = 0; i < M; i++){ int item1, item2, score; cin >> item1 >> item2 >> score; val[item1][item2] = score; } vector<int> ord(N); for(int i = 0; i < N; i++){ ord[i] = i; } int ans = 0; do{ int score = 0; for(int i = 0; i < N; i++){ for(int j = i+1; j < N; j++){ score += val[ord[i]][ord[j]]; } } ans = max(ans, score); }while(next_permutation(ord.begin(), ord.end())); cout << ans << endl; return 0; }