@[yangyibangyi](/space/show?uid=90593) tel是什么鬼
by andyli @ 2018-07-15 11:15:12
@[yangyibangyi](/space/show?uid=90593) 这题是动态规划呀,不是深搜
by andyli @ 2018-07-15 11:15:57
@[yangyibangyi](/space/show?uid=90593) 你看我代码:
```cpp
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std;
const int maxn = 1050;
int A[maxn][maxn], d[maxn][maxn];
int n;
int dp(int i, int j)
{
if (d[i][j] >= 0)
return d[i][j];
return d[i][j] = A[i][j] + (i == n ? 0 : max(dp(i + 1, j), dp(i + 1, j + 1)));
}
int main()
{
cin >> n;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= i; j++)
cin >> A[i][j];
memset(d, -1, sizeof(d));
cout << dp(1, 1) << endl;
return 0;
}
```
by andyli @ 2018-07-15 11:16:24
搜索的话你需要记忆化搜索,不然肯定超时喽
by 初音Miku @ 2018-07-15 11:17:49
@[初音Miku](/space/show?uid=79019) 好的 谢谢!
by 老y万人敬仰。 @ 2018-07-15 11:22:21
@[andyli](/space/show?uid=84282) 感谢!!!
by 老y万人敬仰。 @ 2018-07-15 11:22:32
tel是什么鬼?
by Victory_Defeat @ 2018-07-15 12:27:30
`#define tel TLE`
by 2017gdgzoi999 @ 2018-12-21 20:28:33