結果
問題 | No.90 品物の並び替え |
ユーザー | Ysmr_Ry |
提出日時 | 2015-01-05 10:52:10 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 476 ms / 5,000 ms |
コード長 | 664 bytes |
コンパイル時間 | 524 ms |
コンパイル使用メモリ | 45,452 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-03 22:03:07 |
合計ジャッジ時間 | 3,174 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 35 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 4 ms
4,380 KB |
testcase_04 | AC | 5 ms
4,380 KB |
testcase_05 | AC | 41 ms
4,376 KB |
testcase_06 | AC | 28 ms
4,376 KB |
testcase_07 | AC | 2 ms
4,376 KB |
testcase_08 | AC | 2 ms
4,376 KB |
testcase_09 | AC | 476 ms
4,380 KB |
ソースコード
#include<cstdio> #include<algorithm> #include<numeric> #include<vector> #define rep(i,a) for(int i=0;i<(a);++i) #define all(a) (a).begin(), (a).end() const int MAX_N = 9, MAX_M = 72; int N, M; int item[2][MAX_M], score[MAX_M]; int main() { scanf( "%d%d", &N, &M ); rep( i, M ) scanf( "%d%d%d", item[0]+i, item[1]+i, score+i ); std::vector<int> v( N ); std::iota( all(v), 0 ); int ans = 0; do { int cnt = 0; rep( i, M ) if( std::find( all(v), item[0][i] )-v.begin() < std::find( all(v), item[1][i] )-v.begin() ) cnt += score[i]; ans = std::max( ans, cnt ); } while( std::next_permutation( all(v) ) ); printf( "%d\n", ans ); return 0; }