当前位置:网站首页>[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;
}
边栏推荐
猜你喜欢

Performance test process

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

赶紧进来!!轻松掌握C语言“顺序”、“分支”、“循环”三大结构

Read "effective managers - Drucker"

关于numpy基础用法的一个整理

Tips for using the built-in variable props of BeanShell

SSM integration

I'm interested in reading efficient reading - the most cost-effective self investment

Some experience of using D2L package and related environment configuration

C语言从入门到入土——函数
随机推荐
Text summary acl2021
Relationship between sample and population in Statistics: sample success ratio + central limit theorem (sample mean)
MySQL connection
【dp】数字三角形
文本摘要 ACL2021
MQTT学习
FTP file transfer protocol
String的字符串常量池和intern()详解
anaconda常用命令的整理
输入若干数据,找出最大值输出。(键盘和文件读取)
Installation and login login
C语言进阶篇 七.程序的编译和预处理
Career planning route
Machine vision learning summary
libevent与多线程
你真的知道判断语句吗?
SSM整合
Hotel IPTV digital TV system solution
Add, delete, modify and check JDBC
ssm的整合