結果

問題 No.90 品物の並び替え
ユーザー vintersn0wvintersn0w
提出日時 2018-05-27 22:46:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 17 ms / 5,000 ms
コード長 789 bytes
コンパイル時間 595 ms
コンパイル使用メモリ 74,004 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-12 19:44:44
合計ジャッジ時間 1,299 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <cmath>

using namespace std;
typedef uint uint32_t;

int N, M;
int scores[9][9] = {};
int items[9] = {0,1,2,3,4,5,6,7,8};

void print_i() {
    for (int i = 0; i < N; i++) {
        cout << items[i] << ' ';
    }
    cout << endl;
}

int main() {
    cin >> N >> M;
    int i,j,s;
    for (int k = 0; k < M; k++) {
        cin >> i >> j >> s;
        scores[i][j] = s;
    }

    int m = 0;
    do {
        s = 0;
        // print_i();
        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                s += scores[items[i]][items[j]];
            }
        }
        if (m < s) m = s;
    } while (next_permutation(items, items + N));

    
    cout << m << endl;
}
0