結果

問題 No.90 品物の並び替え
ユーザー DaYuanChiDaYuanChi
提出日時 2021-01-23 00:47:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 14 ms / 5,000 ms
コード長 551 bytes
コンパイル時間 1,441 ms
コンパイル使用メモリ 166,776 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-28 10:25:11
合計ジャッジ時間 2,105 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int p[15][15];

int main(){
  int n, m; cin >> n >> m;
  for(int i = 0; i < m; i++){
    int a, b, score; cin >> a >> b >> score;
    p[a][b] = score;
  }
  vector<int> v;
  for(int i = 0; i < n; i++) v.push_back(i);
  int ans = 0;
  do{
    int now = 0;
    for(int i = 0; i < n-1; i++){
      for(int j = i+1; j < n; j++){
        now += p[v[i]][v[j]]; 
      }
    }
    ans = max(ans, now);
  }while(next_permutation(v.begin(), v.end()));
  cout << ans << endl;
  return 0;
}
  
0