USACO1.6 Number Triangles [dp-简单dp]
2024-08-31 05:18:03
回忆童年
/*
ID: Starry21
LANG: C++
TASK: ariprog
*/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
#define N 1005
#define ll long long
#define INF 0x3f3f3f3f
int a[N][N],dp[N][N];
int n;
int main()
{
//freopen("ariprog.in","r",stdin);
//freopen("ariprog.out","w",stdout);
scanf("%d",&n);
for(int i=;i<=n;i++)
for(int j=;j<=i;j++)
{
scanf("%d",&a[i][j]);
dp[i][j]=a[i][j];
}
for(int i=n-;i>=;i--)
for(int j=;j<=i;j++)
dp[i][j]=max(dp[i+][j],dp[i+][j+])+a[i][j];
printf("%d\n",dp[][]);
return ;
}
Code
最新文章
- bzoj4555题解
- Java数据结构之表的增删对比---ArrayList与LinkedList之一
- QQ空间HD(3)-Modal的切换效果总结
- Android中的dispatchTouchEvent()、onInterceptTouchEvent()和onTouchEvent()
- Loadrunner中web_reg_save_param的使用详解
- 自制Chrome拓展
- 一步步优化JVM五:优化延迟或者响应时间(1)
- FreeBSD下查看各软件版本命令
- API 版本控制
- Android(java)学习笔记84:自定义异常类
- 24种设计模式--状态模式【State Pattern】
- APNs-远程推送
- hdoj 5137 How Many Maos Does the Guanxi Worth【最短路枚举+删边】
- js 模拟QQ聊天窗口图片播放效果(带滚轮缩放)
- [原译]在mongoose中对Array Schema进行增删改
- std::function 测试
- request参数集合绑定实体实现defaultmodebinder
- 理解angularJs中的$on,$broadcast,$emit
- js测试地址
- pypinyin, jieba分词与Gensim
热门文章
- 如何理解react中的super() super(props)
- buuctf@pwn1_sctf_2016
- Python&;R&;Matlab:批量生成变量
- SQLSERVER 连接常见问题
- QT:QSS完全无效的原因
- Spring后台,通过name取值
- Python初记
- POJ 2299 Ultra-QuickSort (树状数组 &;&; 离散化)
- Super Mario(主席树)
- php 将几个变量合为数组,变量名和值对应