全部评论 1

  • #include<bits/stdc++.h>
    using namespace std;
    
    long long n, m, a[105][105];
    
    int main()
    {
    	cin >> n;
    	for (int i = 1; i <= n; i++)
    	{
    		for (int j = 1; j <= i; j++)
    		{
    			cin >> 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;
    }
    

    2024-08-17 来自 广东

    0
首页