洛谷 P1216
#include <iostream>
#include <vector>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <chrono>
#include <ctime>
#include <cmath>
#include <cctype>
#include <string>
#include <cstdio>
#include <iomanip>#include <thread>
#include <mutex>
#include <condition_variable>
#include <functional>
#include <iterator>
using namespace std;
int dp[1005][1005] = {
0};int main()
{
int r;cin >> r;int t = 1;while (t <= r) {
for (int i = 1; i <= t; ++i)cin >> dp[t][i];++t;}for (int i = r - 1; i >= 1; --i) {
for (int j = 1; j <= i; ++j) {
dp[i][j] = dp[i][j] + max(dp[i + 1][j], dp[i + 1][j + 1]);}}cout << dp[1][1] << endl;return 0;
}