結果
問題 |
No.90 品物の並び替え
|
ユーザー |
|
提出日時 | 2014-12-09 15:41:26 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 34 ms / 5,000 ms |
コード長 | 514 bytes |
コンパイル時間 | 642 ms |
コンパイル使用メモリ | 56,240 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-11 18:54:47 |
合計ジャッジ時間 | 990 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
#include <iostream> using namespace std; int N, M; int score[11][11]; int dfs(int mask){ int res = 0; for(int i=0;i<N;i++){ if((mask >> i) & 1)continue; int tmp = 0; for(int j=0;j<N;j++){ if((mask >> j) & 1){ tmp += score[j][i]; } } tmp += dfs(mask | (1 << i)); res = max(res, tmp); } return res; } int main(){ cin >> N >> M; for(int i=0;i<M;i++){ int a, b, c; cin >> a >> b >> c; score[a][b] = c; } cout << dfs(0) << endl; return 0; }