結果

問題 No.90 品物の並び替え
ユーザー DialBirdDialBird
提出日時 2017-03-08 11:39:18
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 627 bytes
コンパイル時間 1,519 ms
コンパイル使用メモリ 146,524 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 23:30:00
合計ジャッジ時間 2,203 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,first,last) for (int i=first;i<last;++i)
#define MAX(x,y) (x > y ? x : y)
#define MIN(x,y) (x < y ? x : y)

int N, M;
int scores[10][10];
vector<int> nums;

int main(){
  cin >> N >> M;

  REP(i,0,N){
    nums.push_back(i);
  }

  int it_1, it_2, s;
  REP(i,0,M){
    cin >> it_1 >> it_2 >> s;
    scores[it_1][it_2] = s;
  }

  int ans = 0;
  do {
    int sum = 0;
    REP(i,0,N-1){
      REP(j,i+1,N){
        sum += scores[nums[i]][nums[j]];
      }
    }
    ans = MAX(sum, ans);
  } while (next_permutation(nums.begin(), nums.end()));

  cout << ans << endl;
}
0