結果
| 問題 | No.90 品物の並び替え |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-11-21 00:09:37 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 5,000 ms |
| コード長 | 692 bytes |
| 記録 | |
| コンパイル時間 | 1,134 ms |
| コンパイル使用メモリ | 192,240 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-05-21 15:35:50 |
| 合計ジャッジ時間 | 1,937 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}