#include #include #include #include #include using namespace std; int main() { int n, m; int a, b, c; cin >> n >> m; vector< vector > score(n, vector(n, 0)); for (int i = 0; i < m; i++) { cin >> a >> b >> c; score[a][b] = c; } vector order(n, 0); for (int i = 0; i < n; i++) { order[i] = i; } int ans = 0; int total; do { total = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { total += score[order[i]][order[j]]; } } ans = max(ans, total); } while (next_permutation(order.begin(), order.end())); cout << ans << endl; return 0; }