結果
| 問題 |
No.90 品物の並び替え
|
| コンテスト | |
| ユーザー |
otsnsk
|
| 提出日時 | 2014-12-17 18:59:13 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 17 ms / 5,000 ms |
| コード長 | 785 bytes |
| コンパイル時間 | 531 ms |
| コンパイル使用メモリ | 57,920 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-12 01:01:39 |
| 合計ジャッジ時間 | 1,156 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
int score[10][10];
int main() {
int N, M, i1, i2, s;
int row[10];
int total, max_total;
cin >> N >> M;
for (int i = 0; i < M; i++) {
cin >> i1 >> i2 >> s;
score[i1][i2] = s;
}
for (int i = 0; i < N; i++) {
row[i] = i;
}
max_total = 0;
do {
// for (int i = 0; i < N; i++) cout << row[i]; cout << "\n";
total = 0;
for (int i = 0; i < N-1; i++) {
for (int j = i; j < N; j++) {
total += score[row[i]][row[j]];
}
}
max_total = max(max_total, total);
}
while (next_permutation(row, row+N));
cout << max_total << endl;
return 0;
}
otsnsk