33分,求助
查看原帖
33分,求助
735935
Etic_HAO楼主2022/8/1 09:21
#include <bits/stdc++.h>
using namespace std;

int r,f[1005][1005];

int main(){
	ios::sync_with_stdio(false);
	cin>>r;
	for(int i=1;i<=r;i++){
		for(int j=1;j<=i;j++){
			cin>>f[i][j];
		}
	}
	for(int i=4;i>=1;i--){
		for(int j=1;j<=i;j++){
			if(f[i+1][j]>f[i+1][j+1]){
				f[i][j]+=f[i+1][j];
			}
			else{
				f[i][j]+=f[i+1][j+1];
			}
		}
	}
	cout<<f[1][1];
}

谢谢

2022/8/1 09:21
加载中...