結果

問題 No.90 品物の並び替え
ユーザー kpinkcatkpinkcat
提出日時 2023-10-16 00:11:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 13 ms / 5,000 ms
コード長 731 bytes
コンパイル時間 1,150 ms
コンパイル使用メモリ 103,336 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-16 00:11:35
合計ジャッジ時間 1,783 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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, arr[9], list[90][90];
    cin >> n >> m;
    for (int i = 0; i < n; i++) arr[i] = i;
    for (int i = 0; i < m; i++) {
        int t1, t2, t3;
        cin >> t1 >> t2 >> t3;
        list[t1][t2] = t3;
    }
    do {
        ll tmp = 0;
        for (int i = 0; i < n; i++){
            for (int j = i+1; j < n; j++){
                tmp += list[arr[i]][arr[j]];
            }
        }
        ans = max(ans, tmp);
    }while (next_permutation(arr, arr+n));
    cout << ans << endl;
}
0