【Luogu1508】Likecloud-吃、吃、吃

problem

solution

codes

#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 1010;
int m, n, f[maxn][maxn];
int main(){
    cin>>m>>n;
    for(int i = 1; i <= m; i++)
        for(int j = 1; j <= n; j++)
            cin>>f[i][j];
    for(int i = 2; i <= m+1; i++)
        for(int j = 1; j <= n; j++)
            f[i][j] = f[i][j]+max(f[i-1][j],max(f[i-1][j-1],f[i-1][j+1]));
    cout<<f[m+1][(n+1)/2]<<"
";
    return 0;
}
原文地址:https://www.cnblogs.com/gwj1314/p/9444695.html