結果

問題 No.90 品物の並び替え
ユーザー troro_kelptroro_kelp
提出日時 2018-12-23 21:41:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 108 ms / 5,000 ms
コード長 821 bytes
コンパイル時間 1,003 ms
コンパイル使用メモリ 95,520 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-26 02:38:41
合計ジャッジ時間 1,676 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,372 KB
testcase_01 AC 9 ms
4,372 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 2 ms
4,372 KB
testcase_04 AC 2 ms
4,372 KB
testcase_05 AC 10 ms
4,372 KB
testcase_06 AC 7 ms
4,372 KB
testcase_07 AC 2 ms
4,372 KB
testcase_08 AC 1 ms
4,372 KB
testcase_09 AC 108 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using ll = long long;
using namespace std;

struct Data
{
    int item1, item2, score;
};

vector<int> v;
vector<Data> arr;
int main(void)
{
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < N; ++i)
        v.push_back(i);

    for (int i = 0; i < M; ++i)
    {
        Data d;
        cin >> d.item1 >> d.item2 >> d.score;
        arr.push_back(d);
    }

    int ans = 0;

    do
    {
        int t = 0;
        for (int i = 0; i < M; ++i)
        {
            if (v[arr[i].item1] < v[arr[i].item2])
                t += arr[i].score;
        }
        ans = max(ans, t);
    } while (next_permutation(v.begin(), v.end()));

    cout << ans << endl;
    return 0;
}
0