当前位置:网站首页>[DP] number triangle
[DP] number triangle
2022-07-24 05:27:00 【rejudge】
https://www.acwing.com/problem/content/900/
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=1100;
int v[N][N];
int f[N][N];
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
for(int j=1;j<=i;j++)
cin>>v[i][j];
for(int i=1;i<=n;i++) f[n][i]=v[n][i];
for(int i=n-1;i>=1;i--)
{
for(int j=1;j<=i;j++)
{
f[i][j]=max(f[i+1][j],f[i+1][j+1])+v[i][j];
}
}
cout<<f[1][1];
return 0;
}
边栏推荐
- JDBC encapsulates a parent class to reduce code duplication
- 你真的知道判断语句吗?
- String的字符串常量池和intern()详解
- Collation of commonly used Anaconda commands
- 在屏幕上绘制一个运动的茶壶,茶壶先慢慢向屏幕里面移动,越变越小,越变越模糊;然后慢慢变大,越变越清晰,一直往返重复。为场景添加光照,材质和雾效果。通过键盘’a’’s’’d’来选择不同的雾效模式
- BeanShell built-in variable CTX
- Text summary acl2021
- NFS shared services
- c2-随机产生函数种子seed、numpy.random.seed()、tf.random.set_seed学习+转载整理
- Detailed explanation of string constant pool and intern() of string
猜你喜欢

Reading excerpts from Liu run's "bottom logic"
![[deep learning] (III) image classification](/img/8a/86b8ec6951f112f47be816378ab7d8.png)
[deep learning] (III) image classification

Introduction to reflection

Machine vision learning summary

jdbc封装一个父类减少代码重复

Pure white tutorial using Druid database connection pool in idea

九大排序实现与比较(万字总结)

递归还能这么玩?递归实现扫雷游戏

【sklearn】RF 交叉验证 袋外数据 参数学习曲线 网格搜索

Introduction to threads
随机推荐
C语言实现三子棋?五子棋?不,是n子棋
Jsp+dao integration
一步一步带你学C(其一)
thread
好的程序员与不好的程序员
一步一步带你学C(其二)
T 1-5
Some experience of using D2L package and related environment configuration
I'm interested in reading efficient reading - the most cost-effective self investment
OSS file upload
反射的介绍
【dp】数字三角形
泛型和注解
day(0~6)代表每月第一天起始位置,stop代表每月天数,每天之间空两个空格。输入不同的day和stop,输出每月日历的样子。假设day为2,stop为31,则输出样式为
anaconda常用命令的整理
4. 在屏幕上绘制一个红色三角形,一个黄色正方形。三角形在后,小;正方形在前,大。使用融合技术,使得可以透过正方形看到三角形,源和目标融合因子分别为GL_SRC_ALPHA和GL_ONE_MINUS
jdbc的增删改查
C语言从入门到入土(三)
Redis的使用
C文件读写加链表增删改查