wsm

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

Chenyuanyang0001 @ 2017-07-06 14:29:41

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;
int a[100+10][100+10];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        {for(int j=1;j<=i;j++)
            scanf("%d",&a[i][j]);}
    for(int i=n-1;i>=1;i--)
        {for(int j=1;j<=i;j++)
            a[i][j]+=max(a[i+1][j],a[i+1][j+1]);}
    cout<<a[1][1]<<endl;            
    return 0;
}

by d3NtMDAw @ 2017-07-21 08:21:38

叫我作甚


|