結果

問題 No.90 品物の並び替え
ユーザー motxxmotxx
提出日時 2014-12-07 19:20:22
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 22 ms / 5,000 ms
コード長 679 bytes
コンパイル時間 1,156 ms
コンパイル使用メモリ 146,564 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-02 09:19:36
合計ジャッジ時間 1,799 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)

string ban[2] = {"oda", "yukiko"};

#define SQ(x) ((x)*(x))

int main() {
  
  int N, M; cin >> N >> M;
  int score[10][10] = {};
  rep(i, M) {
    int a, b; cin >> a >> b;
    cin >> score[a][b];
  }
  
  int per[N]; rep(i, N) per[i] = i;
  int ans = 0;
  do {
    int sum = 0;
    rep(i, N) REP(j, i, N) {
      int a = per[i], b = per[j];
      if(a > b) swap(a, b);
      sum += score[per[i]][per[j]];
    }
    ans = max(ans, sum);
  } while(next_permutation(per, per+N));
  
  cout << ans << endl;
  
  return 0;
}
0