你写两个int main()是什么鬼
by PRXOR @ 2019-08-13 14:53:47
@[奔跑的五花肉](/space/show?uid=84068) 请问您代码复制两份的意义是什么?
by S1nner @ 2019-08-13 14:54:06
$\text{你在洛谷IDE上面编译试试?}$
by Zxc200611 @ 2019-08-13 14:56:14
@[奔跑的五花肉](/space/show?uid=84068) 你为什么用%d读入long long
不应该用%lld吗?
by PRXOR @ 2019-08-13 14:56:57
啊啊啊啊手残了
忽略下面的
by 奔跑的五花肉 @ 2019-08-13 14:58:30
应该是这样
```cpp
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
using namespace std;
#define ll long long
ll n,m;
ll mp[2020][2020];
int main(){
scanf("%d%d", &n, &m);
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= m; ++j){
scanf("%d", &mp[i][j]);
}
ll f[1002][1002];
memset(f,0,sizeof f);
int x = m / 2 + 1;
int y = n;
for(int i = 1; i <= n; ++i)
for(int j = m; j >= 1; --j)
f[i][j] = max(f[i - 1][j - 1],max(f[i - 1][j],f[i - 1][j + 1])) + mp[i][j];
cout<<f[y][x]<<endl;
return 0;
}
```
by 奔跑的五花肉 @ 2019-08-13 14:59:17
@[奔跑的五花肉](/space/show?uid=84068) 大数组最好开成全局变量,不要在 ```int main``` 里开大数组。 全局变量在静态存储区分配内存,局部变量是在栈上分配内存空间的,容易造成栈溢出。
还有```long long```的输入输出用```%lld```
by JT_kk @ 2019-08-13 15:15:22
@[奔跑的五花肉](/space/show?uid=84068) 您的```sizeof```格式有误
by _gifbmp @ 2019-08-13 15:20:36
@[奔跑的五花肉](/space/show?uid=84068)
$$memset(f,0,sizeof f);$$
应为
$$memset(f,0,sizeof(f));$$
by Stephen_Curry @ 2019-08-13 15:49:51
@[Stephen_Curry](/space/show?uid=212267) 一个空格也是可以的
by 奔跑的五花肉 @ 2019-08-13 16:05:17