結果

問題 No.90 品物の並び替え
ユーザー pasoconhoshiipasoconhoshii
提出日時 2019-02-11 16:06:31
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 108 ms / 5,000 ms
コード長 731 bytes
コンパイル時間 3,429 ms
コンパイル使用メモリ 146,956 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 15:23:15
合計ジャッジ時間 2,922 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 9 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 10 ms
4,380 KB
testcase_06 AC 7 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 108 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// FROM : https://yukicoder.me/submissions/306204
//
#include <bits/stdc++.h>
#include <iostream>
using namespace std;

struct Data
{
  int item1, item2, score;
};

int main()
{
  long long N,M;
  cin >> N >> M;
  vector<Data> scores(M);
  vector<long long> v(N);

  for (int i=0; i < N; i++) {
    v[i] = i;
  }

  for (long long i=0; i<M; i++) {
    int a,b,c;
    struct Data d;
    cin >> d.item1 >> d.item2 >> d.score;
    scores[i] = d;
  }

  long long ans = 0;
  do {
    long long  t = 0;
    for (int i = 0; i<M; i++) {
      if (v[scores[i].item1] < v[scores[i].item2]) 
        t += scores[i].score;
    }
    ans = max(ans, t);
  } while (next_permutation(v.begin(), v.end()));
  cout << ans << endl;



  return 0;
}
0