#include #include #include using namespace std; const int MAX_N = 16; int dp[1 << MAX_N] = {0}; int score_tbl[MAX_N][MAX_N] = {0}; int main(){ int n,m; cin >> n >> m; int a,b,score; for(int i = 0; i < m; i++){ cin >> a >> b >> score; score_tbl[a][b] = score; } for(int i = 0; i < 1 << n; i++){ for(int j = 0; j < m; j++){ for(int k = 0; k < m; k++){ if(((i >> j) & 1) && !((i >> k) & 1)){ dp[i | 1 << k] = max(dp[i | 1 << k],dp[i] + score_tbl[j][k]); } } } } cout << dp[(1 << n)-1] << endl; return 0; }