深渊龙谷 @ 2019-01-28 20:16:20
大佬求助,最后一个样例RE
#include <bits/stdc++.h>
using namespace std;
int a[1000][1000];
int main(){
int n;
int ans=0;
cin>>n;
for (int i=1;i<=n;i++){
for (int j=1;j<=i;j++){
cin>>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],a[i-1][j-1]);
}
}
for (int i=1;i<=n;i++){
ans=max(a[n][i],ans);
}
cout<<ans;
return 0;
}
by Lucifer_Bartholomew @ 2019-01-28 20:20:28
数组开到[1001][1001]