/*
ID: awsd1231
PROG: numtri
LANG: C++
*/
#include<iostream>
#include<cstdio>
using namespace std;
int a[1001], b[1001];
int* x = a, *y = b, *t;
int n;
int ans(int* x, int n) {
int maxAns = x[0];
for(int i = 0; i != n; ++i) {
if(x[i] > maxAns) maxAns = x[i];
}
return maxAns;
}
int main() {
freopen("numtri.in", "r", stdin);
freopen("numtri.out", "w", stdout);
cin >> n;
cin >> x[0];
for(int i = 1; i != n; ++i) {
for(int j = 0; j != i + 1; ++j) {
cin >> y[j];
if(!j) y[j] = y[j] + x[j];
else y[j] += max(x[j], x[j-1]);
}
t = x; x = y; y = t;
}
cout << ans(x, n) << endl;
return 0;
}
时间: 2024-10-12 09:12:18