結果
問題 | No.90 品物の並び替え |
ユーザー |
![]() |
提出日時 | 2023-10-15 18:51:00 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 208 ms / 5,000 ms |
コード長 | 873 bytes |
コンパイル時間 | 963 ms |
コンパイル使用メモリ | 108,568 KB |
最終ジャッジ日時 | 2025-02-17 07:57:53 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:32:13: warning: ‘f’ may be used uninitialized [-Wmaybe-uninitialized] 32 | if (f < b) tmp += list[i][2]; | ^~ main.cpp:27:17: note: ‘f’ was declared here 27 | int f, b; | ^ main.cpp:32:13: warning: ‘b’ may be used uninitialized [-Wmaybe-uninitialized] 32 | if (f < b) tmp += list[i][2]; | ^~ main.cpp:27:20: note: ‘b’ was declared here 27 | int f, b; | ^
ソースコード
#include<iostream>#include<iomanip>#include<string>#include<algorithm>#include<vector>#include<set>#include<list>#include<queue>#include<math.h>#include<bitset>using ll = long long;using namespace std;int main(){ll n, m, ans = 0;cin >> n >> m;vector<vector<int>> list(m, vector<int>(3));vector<int> arr(n);for (int i = 0; i < n; i++) arr[i] = i;for (int i = 0; i < m; i++) cin >> list[i][0] >> list[i][1] >> list[i][2];do {ll tmp = 0;for (int i = 0; i < m; i++){int f, b;for (int j = 0; j < n; j++){if (arr[j] == list[i][0]) f = j;if (arr[j] == list[i][1]) b = j;}if (f < b) tmp += list[i][2];}ans = max(ans, tmp);}while (next_permutation(arr.begin(), arr.end()));cout << ans << endl;}