Loading docs/search/opt.md +21 −23 Original line number Diff line number Diff line Loading @@ -115,20 +115,20 @@ void dfs(传入数值) { 输入样例: ```text ```text 5 9 2 9 1 9 1 9 8 9 6 9 9 9 9 1 8 8 1 8 4 9 1 7 8 9 ``` ``` 输出样例: ```text ```text 5 ``` ``` **分析** Loading @@ -144,8 +144,7 @@ int time[N][N]; // 完成某项工作所需的时间 int cost_time_total_min;// 完成 n 份工作的最小时间总和 // i 表示第几个人,count 表示工作费用总和 inline void work(int i, int count, int n) { // 如果 i 超出了所能分配的最大工作件数,表示分配完成,并且 count 比原来 // cost_time_total_min 花费少 则更新 cost_time_total_min 的值 // 如果 i 超出了所能分配的最大工作件数,表示分配完成,并且 count 比原来 cost_time_total_min 花费少,则更新 cost_time_total_min 的值 if (i > n && count < cost_time_total_min) { cost_time_total_min = count; return; Loading @@ -160,8 +159,7 @@ inline void work(int i, int count, int n) { is_working[j] = 1; // 工作交给第 i + 1 个人 work(i + 1, count + time[i][j], n); //在一轮迭代完成之后,返回到上一个人,要对此次的工作进行重新分配,将 //is_working[j] 重设为 0 // 在一轮迭代完成之后,返回到上一个人,要对此次的工作进行重新分配,将 is_working[j] 重设为 0 is_working[j] = 0; } } Loading Loading
docs/search/opt.md +21 −23 Original line number Diff line number Diff line Loading @@ -115,20 +115,20 @@ void dfs(传入数值) { 输入样例: ```text ```text 5 9 2 9 1 9 1 9 8 9 6 9 9 9 9 1 8 8 1 8 4 9 1 7 8 9 ``` ``` 输出样例: ```text ```text 5 ``` ``` **分析** Loading @@ -144,8 +144,7 @@ int time[N][N]; // 完成某项工作所需的时间 int cost_time_total_min;// 完成 n 份工作的最小时间总和 // i 表示第几个人,count 表示工作费用总和 inline void work(int i, int count, int n) { // 如果 i 超出了所能分配的最大工作件数,表示分配完成,并且 count 比原来 // cost_time_total_min 花费少 则更新 cost_time_total_min 的值 // 如果 i 超出了所能分配的最大工作件数,表示分配完成,并且 count 比原来 cost_time_total_min 花费少,则更新 cost_time_total_min 的值 if (i > n && count < cost_time_total_min) { cost_time_total_min = count; return; Loading @@ -160,8 +159,7 @@ inline void work(int i, int count, int n) { is_working[j] = 1; // 工作交给第 i + 1 个人 work(i + 1, count + time[i][j], n); //在一轮迭代完成之后,返回到上一个人,要对此次的工作进行重新分配,将 //is_working[j] 重设为 0 // 在一轮迭代完成之后,返回到上一个人,要对此次的工作进行重新分配,将 is_working[j] 重设为 0 is_working[j] = 0; } } Loading