結果

問題 No.90 品物の並び替え
ユーザー kpinkcatkpinkcat
提出日時 2023-10-15 18:51:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 240 ms / 5,000 ms
コード長 873 bytes
コンパイル時間 1,022 ms
コンパイル使用メモリ 107,824 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-15 18:51:02
合計ジャッジ時間 2,131 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 17 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 3 ms
4,352 KB
testcase_05 AC 19 ms
4,352 KB
testcase_06 AC 13 ms
4,352 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 1 ms
4,352 KB
testcase_09 AC 240 ms
4,352 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:32:13: 警告: ‘b’ may be used uninitialized [-Wmaybe-uninitialized]
   32 |             if (f < b) tmp += list[i][2];
      |             ^~
main.cpp:27:20: 備考: ‘b’ はここで定義されています
   27 |             int f, b;
      |                    ^
main.cpp:32:13: 警告: ‘f’ may be used uninitialized [-Wmaybe-uninitialized]
   32 |             if (f < b) tmp += list[i][2];
      |             ^~
main.cpp:27:17: 備考: ‘f’ はここで定義されています
   27 |             int f, b;
      |                 ^

ソースコード

diff #

#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;
}
0