結果
問題 | No.90 品物の並び替え |
ユーザー |
|
提出日時 | 2016-11-21 00:09:37 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 37 ms / 5,000 ms |
コード長 | 692 bytes |
コンパイル時間 | 1,497 ms |
コンパイル使用メモリ | 174,520 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-27 09:17:35 |
合計ジャッジ時間 | 2,010 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
#include <bits/stdc++.h> using namespace std; signed main(){ int N, M; cin >> N >> M; vector< tuple< int, int, int > > abv( M ); for( int i = 0; i < M; ++i ){ int a, b, v; cin >> a >> b >> v; abv[ i ] = tie( a, b, v ); } int ans = 0; vector< int > item( N ); for( int i = 0; i < N; ++i ) item[ i ] = i; do{ int sum = 0; vector< int > pos( N ); for( int i = 0; i < N; ++i ) pos[ item[ i ] ] = i; for( int i = 0; i < M; ++i ){ int a, b, v; tie( a, b, v ) = abv[ i ]; sum += ( pos[ a ] < pos[ b ] ) * v; } ans = max( ans, sum ); } while( next_permutation( item.begin(), item.end() ) ); cout << ans << endl; return 0; }