1 solutions

  • 0
    @ 2024-3-17 12:53:44
    #include<bits/stdc++.h>
    using namespace std;
    
    const int N = 1010;
    
    int ans[N][N],n;
    
    int main()
    {
        cin>>n;
        for(int i = 1;i<=n;i++)//存放图
        for(int j = 1;j<=i;j++)
        cin>>ans[i][j];
    
    
    //简单dp 从下往上推到顶
        for(int i = n;i>=1;i--)
        for(int j = 1;j<=i;j++)
            ans[i-1][j] += max(ans[i][j],ans[i][j+1]);
            
                
        cout<<ans[1][1];
    	return 0;
    }
    

    Information

    ID
    6869
    Time
    1000ms
    Memory
    125MiB
    Difficulty
    10
    Tags
    # Submissions
    1
    Accepted
    1
    Uploaded By