結果
| 問題 |
No.357 品物の並び替え (Middle)
|
| コンテスト | |
| ユーザー |
Kutimoti_T
|
| 提出日時 | 2018-06-20 21:23:48 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 5,000 ms |
| コード長 | 571 bytes |
| コンパイル時間 | 1,115 ms |
| コンパイル使用メモリ | 158,328 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-30 17:27:18 |
| 合計ジャッジ時間 | 1,776 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int N,M;
i64 score[14][14];
i64 dp[1 << 14];
int main(){
cin >> N >> M;
for(int i = 0;i < M;i++){
i64 a,b,c;
cin >> a >> b >> c;
score[a][b] = c;
}
for(int s = 0;s < (1 << N);s++){
for(int p = 0;p < N;p++){
int t = s | (1 << p);
if(t == s) continue;
i64 res = 0;
for(int i = 0;i < N;i++){
if(s & (1 << i)){
res += score[i][p];
}
}
dp[t] = max(dp[t],dp[s] + res);
}
}
cout << dp[(1 << N) - 1] << endl;
}
Kutimoti_T