結果
問題 | No.90 品物の並び替え |
ユーザー | Mcpu3 |
提出日時 | 2019-03-08 16:07:43 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 231 ms / 5,000 ms |
コード長 | 665 bytes |
コンパイル時間 | 562 ms |
コンパイル使用メモリ | 72,008 KB |
実行使用メモリ | 4,500 KB |
最終ジャッジ日時 | 2023-09-05 19:40:09 |
合計ジャッジ時間 | 1,485 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 18 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 2 ms
4,380 KB |
testcase_04 | AC | 3 ms
4,380 KB |
testcase_05 | AC | 21 ms
4,376 KB |
testcase_06 | AC | 15 ms
4,380 KB |
testcase_07 | AC | 2 ms
4,376 KB |
testcase_08 | AC | 1 ms
4,380 KB |
testcase_09 | AC | 231 ms
4,500 KB |
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内: main.cpp:22:25: 警告: ‘tmp3’ may be used uninitialized [-Wmaybe-uninitialized] 22 | if (tmp2 < tmp3) sum += score[j]; | ^~ main.cpp:17:35: 備考: ‘tmp3’ はここで定義されています 17 | int tmp2, tmp3; | ^~~~ main.cpp:22:25: 警告: ‘tmp2’ may be used uninitialized [-Wmaybe-uninitialized] 22 | if (tmp2 < tmp3) sum += score[j]; | ^~ main.cpp:17:29: 備考: ‘tmp2’ はここで定義されています 17 | int tmp2, tmp3; | ^~~~
ソースコード
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> item1(M), item2(M), score(M); for (int i = 0; i < M; ++i) cin >> item1[i] >> item2[i] >> score[i]; vector<int> tmp1(N); for (int i = 0; i < N; ++i) tmp1[i] = i; int ans = 0; do { int sum = 0; for (int j = 0; j < M; ++j) { int tmp2, tmp3; for (int k = 0; k < N; ++k) { if (tmp1[k] == item1[j]) tmp2 = k; else if (tmp1[k] == item2[j]) tmp3 = k; } if (tmp2 < tmp3) sum += score[j]; } ans = max(sum, ans); } while (next_permutation(tmp1.begin(), tmp1.end())); cout << ans; }