cao_20115 @ 2024-04-29 22:43:35
#include <bits/stdc++.h>
using namespace std;
int a[1010][1010];
int r;
int main(){
scanf("%d", &r);
for (int i = 1; i <= r; ++i) {
for (int j = 1; j <= i; ++j) {
scanf("%d", &a[i][j]);
}
}
for (int i = r - 1; i >= 1; --i) {
for (int j = 1; i <= i; ++j) {
a[i][j] = max(a[i][j] + a[i + 1][j], a[i][j] + a[i + 1][j + 1]);
}
}
printf("%d", a[1][1]);
return 0;
}
身为新手的我脑子干烧了
by guer_loser_lcz @ 2024-04-29 22:47:41
第二层循环i<=i??? @cao_20115
by guer_loser_lcz @ 2024-04-29 22:48:45
@cao_20115 改成j<=i。
by guer_loser_lcz @ 2024-04-29 22:49:04
@cao_20115 求关。
by cao_20115 @ 2024-04-29 22:51:11
@lczcy1 栓Q,已关~