結果

問題 No.90 品物の並び替え
ユーザー troro_kelp
提出日時 2018-12-23 21:41:56
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 109 ms / 5,000 ms
コード長 821 bytes
コンパイル時間 1,555 ms
コンパイル使用メモリ 95,216 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-25 10:39:34
合計ジャッジ時間 1,479 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

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