看不透QAQ

P1216 [USACO1.5] [IOI1994]数字三角形 Number Triangles

jun1lesszZZ @ 2019-03-31 08:27:27

过样例后提交44分,测了你谷提供的两个错误数据点, 然后??? https://i.loli.net/2019/03/31/5ca0089a5c965.png https://i.loli.net/2019/03/31/5ca009226e81b.png

代码

#include<bits/stdc++.h>
using namespace std;
int a[2000][2000];
int main()
{
    int n,ans;
    scanf("%d",&n);
    for(int i = 1;i <= n;i ++)
    {
         for(int j = 1;j <= i;j ++)
          scanf("%d",&a[i][j]);
    }
    for(int i = 1;i <= n;i ++)
    {
        for(int j = 1;j <= i;j ++)
        {
            a[i][j] = max(a[i - 1][j - 1],a[i - 1][j]) + a[i][j];
            ans = max(ans,a[i][j]);
        }
    }
    printf("%d",ans);                               
}

by jun1lesszZZ @ 2019-03-31 08:29:48

发重了,还有一个是样例https://i.loli.net/2019/03/31/5ca009d88438f.png


by jun1lesszZZ @ 2019-03-31 08:30:31

这个


by dead_gun @ 2019-03-31 10:09:04

@zZZ_han 你的ans!=0


by djwj233 @ 2020-02-10 13:13:26

@lv_mao_da_lao 头次听说这是贪心


|