假设圣诞树从1层到n层的排列形式是类似于一张链状的图,那么在其边缘衍生出的若干条指向下层某元素的边与链状图就组成了一张有向无环图(只能指向一个元素且下层元素不可指向上层)。对每个点进行记忆化搜索(状态转移:现在的值加上以下所连接的值),再取最大值即可。
//#include<pch.h>
#include <iostream>
#include <cstdio>
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <stack>
#include <iomanip>
#include <cstring>
#include <cmath>
#define DETERMINATION main
#define lldin(a) scanf_s("%lld", &a)
#define println(a) printf("%lld\n", a)
#define reset(a, b) memset(a, b, sizeof(a))
const int INF = 0x3f3f3f3f;
using namespace std;
const double PI = acos(-1);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int mod = 1000000007;
const int tool_const = 19991126;
const int tool_const2 = 2000;
inline ll lldcin()
{
ll tmp = 0, si = 1;