結果
| 問題 |
No.90 品物の並び替え
|
| コンテスト | |
| ユーザー |
Yang33
|
| 提出日時 | 2018-05-05 01:54:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 95 ms / 5,000 ms |
| コード長 | 963 bytes |
| コンパイル時間 | 1,633 ms |
| コンパイル使用メモリ | 174,960 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-28 01:30:43 |
| 合計ジャッジ時間 | 2,250 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using VS = vector<string>; using LL = long long;
using VI = vector<int>; using VVI = vector<VI>;
#define ALL(a) begin((a)),end((a))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
LL ans = 0LL;
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
int N, M; cin >> N >> M;
using tp = tuple<int, int, int>;
vector<tp>rules(M);
FOR(i, 0, M) {
int a, b, c; cin >> a >> b >> c;
rules[i] = tp(a, b, c);
}
VI a(N, 0);
iota(ALL(a), 0);
do {
LL ret = 0;
VI b(N);
FOR(j, 0, N) {
b[a[j]] = j;
}
for (tp& rule : rules) {
int x, y, z; tie(x, y, z) = rule;
if (b[x] < b[y]) {
ret += z;
}
}
ans = max(ans, ret);
} while (next_permutation(ALL(a)));
cout << ans << "\n";
return 0;
}
Yang33