結果
| 問題 | No.357 品物の並び替え (Middle) | 
| コンテスト | |
| ユーザー |  rapurasu | 
| 提出日時 | 2016-08-12 10:26:58 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 672 bytes | 
| コンパイル時間 | 1,667 ms | 
| コンパイル使用メモリ | 158,308 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-07 12:01:29 | 
| 合計ジャッジ時間 | 2,586 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 1 WA * 17 | 
ソースコード
 #include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long ll;
int N,M;
int v[15][15];
int dp[1<<15];
int main(){
    memset(dp,0,sizeof(dp));
    REP(i,15){
       REP(j,15){
          v[i][j]=0;
       }
    }
    cin>>N>>M;
    REP(i,M){
       int a,b,s;
       cin>>a>>b>>s;
       v[a][b]=s;
    }
    int res=0;
    REP(i,1<<N){
       REP(j,N){
           if((i>>j)&1){
              REP(k,N){
                  if((i>>k)&1){
                     dp[i]=max(dp[i],v[k][j]+dp[i^(1<<j)]);
                  }
              }
           }
       }
    }
    cout<<dp[(1<<N)-1]<<endl;
}
            
            
            
        