結果
| 問題 |
No.90 品物の並び替え
|
| コンテスト | |
| ユーザー |
kyo1
|
| 提出日時 | 2020-10-21 06:12:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 314 ms / 5,000 ms |
| コード長 | 642 bytes |
| コンパイル時間 | 2,679 ms |
| コンパイル使用メモリ | 196,084 KB |
| 最終ジャッジ日時 | 2025-01-15 12:11:32 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N, M;
cin >> N >> M;
vector<int> A(M), B(M), C(M);
for (int i = 0; i < M; i++) {
cin >> A[i] >> B[i] >> C[i];
}
vector<int> P(N);
iota(P.begin(), P.end(), 0);
int res = 0;
do {
int r = 0;
for (int i = 0; i < M; i++) {
int a = 0, b = 0;
for (int j = 0; j < N; j++) {
if (A[i] == P[j]) a = j;
if (B[i] == P[j]) b = j;
}
if (a < b) r += C[i];
}
res = max(res, r);
} while (next_permutation(P.begin(), P.end()));
cout << res << '\n';
return 0;
}
kyo1