#include #include 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; }