#include using namespace std; typedef long long ll; const ll MAX_N = 20; ll dp[1<> N >> M; for(ll i = 0; i < 1<> a >> b >> score; pre[a][b] = score;} for(ll k = 0; k < 1<>i)&1)){ //まだi番目の品物を並べていない ll res = 0; for(ll j = 0; j < N; j++){ if( i != j && ((k >> j) & 1)){ res += pre[i][j]; } } chmax(dp[k+(1<