結果
問題 | No.90 品物の並び替え |
ユーザー | koyumeishi |
提出日時 | 2014-12-07 20:38:57 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 109 ms / 5,000 ms |
コード長 | 793 bytes |
コンパイル時間 | 555 ms |
コンパイル使用メモリ | 77,188 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-02 10:22:13 |
合計ジャッジ時間 | 1,557 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 10 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 2 ms
4,376 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 10 ms
4,376 KB |
testcase_06 | AC | 6 ms
4,376 KB |
testcase_07 | AC | 2 ms
4,376 KB |
testcase_08 | AC | 1 ms
4,380 KB |
testcase_09 | AC | 109 ms
4,380 KB |
ソースコード
#include <iostream> #include <vector> #include <cstdio> #include <sstream> #include <map> #include <string> #include <algorithm> #include <queue> #include <cmath> using namespace std; void dfs(){ } int main(){ int n, m; cin >> n >> m; vector<pair<int,int> > item(m); vector<int> score(m); for(int i=0; i<m; i++){ int x,y,z; cin >> x >> y >> z; item[i] = make_pair(x,y); score[i] = z; } vector<int> v(n); //商品iの位置 for(int i=0; i<n; i++) v[i] = i; long long ans = 0; do{ long long tmp = 0; for(int i=0; i<m; i++){ if( v[ item[i].first ] < v[ item[i].second ] ){ tmp += score[i]; } } ans = max(ans, tmp); }while( next_permutation( v.begin(), v.end() ) ); cout << ans << endl; return 0; }