結果
| 問題 | No.90 品物の並び替え |
| コンテスト | |
| ユーザー |
yuma220284
|
| 提出日時 | 2019-08-10 12:36:11 |
| 言語 | C++11 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
AC
不安定
|
| 実行時間 | 86 ms / 5,000 ms |
| + 612µs | |
| コード長 | 618 bytes |
| 記録 | |
| コンパイル時間 | 869 ms |
| コンパイル使用メモリ | 183,052 KB |
| 実行使用メモリ | 9,820 KB |
| 最終ジャッジ日時 | 2026-10-12 02:03:47 |
| 合計ジャッジ時間 | 2,171 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 10 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
struct item {
int before;
int after;
long long score;
};
int main() {
int N, M;
long long ANS = 0;
vector<int> V;
item X[100];
cin >> N >> M;
for (int i = 0; i < N; i++) V.push_back(i);
for (int i = 0; i < M; i++) {
cin >> X[i].before >> X[i].after >> X[i].score;
}
do {
int Y[9] = {};
for (int i = 0; i < N; i++) {
Y[V[i]] = i;
}
long long COUNT = 0;
for (int i = 0; i < M; i++) {
if (Y[X[i].before] < Y[X[i].after]) COUNT += X[i].score;
}
ANS = max(ANS, COUNT);
} while (next_permutation(V.begin(), V.end()));
cout << ANS << endl;
}
yuma220284