dfs 84分 求大佬帮忙

P2677 [USACO07DEC] Bookshelf 2 B

第一个点WA
by cjihyy @ 2022-07-12 16:56:36


@[cjihyy](/user/490748) 调了你的 dfs 函数,可以通过。 ```cpp void dfs(int x, int b){ if(x > n){ if(sum >= b) res = min(res, sum); return; } dfs(x + 1,b); sum += height[x]; dfs(x + 1,b); sum -= height[x]; } ``` 错的原因是因为,后面的 sum 累加上去忘记减掉了。
by Usada_Pekora @ 2022-07-12 17:08:51


@[Zyingyzzz](/user/434929) 谢谢大佬qaq
by cjihyy @ 2022-07-12 17:10:17


|