当前位置:网站首页>Pass note 【 dynamic planning 】
Pass note 【 dynamic planning 】
2022-06-26 21:50:00 【Alan_ Lowe】
Pass slip 【 Dynamic programming 】
Title Description

AC Code
#include<bits/stdc++.h>
using namespace std;
int n,m; // That's ok 、 Column
int a[55][55], dp[105][55][55];
signed main(){
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>n>>m;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
cin>>a[i][j];
}
}
memset(dp, 0, sizeof dp); // initialization
for (int i = 2; i <= n + m; ++i) {
// The horizontal and vertical coordinates add up to i The diagonal of
for (int y1 = 1; y1 <= m && y1 < i; ++y1) {
// The ordinate of the first point
for (int y2 = 1; y2 <= m && y2 < i ; ++y2) {
// The ordinate of the second point
dp[i][y1][y2] = max(max(dp[i - 1][y1][y2],dp[i - 1][y1 - 1][y2 - 1]),
max(dp[i - 1][y1 - 1][y2],dp[i - 1][y1][y2 - 1]));
dp[i][y1][y2] += a[i - y1][y1];
if(y1 != y2)
dp[i][y1][y2] += a[i - y2][y2];
}
}
}
cout<<dp[n + m][m][m];
return 0;
}
/* 3 3 0 3 9 2 8 5 5 7 0 34 */
边栏推荐
- 如何用 SAP BTP 平台上的图形建模器创建一个 OData 服务
- leetcode:141. 环形链表【哈希表 + 快慢指针】
- 诗尼曼家居冲刺A股:年营收近12亿 红星美凯龙与居然之家是股东
- In 2022, where will the medium and light-weight games go?
- Android IO, a first-line Internet manufacturer, is a collection of real questions for senior Android interviews
- Is there any risk for flush to register and open an account? Is it safe?
- Icml2022 | neurotoxin: a lasting back door to federal learning
- Some ways out for older programmers
- 宝藏又小众的覆盖物PBR多通道贴图素材网站分享
- Hands on deep learning pytorch version 3 - Data Preprocessing
猜你喜欢

Parsing complex JSON in fluent

大龄程序员的一些出路

【 protobuf 】 quelques puits causés par la mise à niveau de protobuf
![leetcode:6103. Delete the minimum score of the edge from the tree [DFS + connected component + value record of the subgraph]](/img/16/8dc63e6494b3f23e2685e287abc94c.png)
leetcode:6103. Delete the minimum score of the edge from the tree [DFS + connected component + value record of the subgraph]

VB.net类库(进阶——2 重载)
![leetcode:1567. 乘积为正数的最长子数组长度【dp[i]表示以i结尾的最大长度】](/img/a4/c5c31de7a0a3b34a188bfec0b5d184.png)
leetcode:1567. 乘积为正数的最长子数组长度【dp[i]表示以i结尾的最大长度】

Module 5 operation

财务费用分析怎么分析

会计要素包括哪些内容

The latest 2022 research review of "continuous learning, CL"
随机推荐
【protobuf 】protobuf 升级后带来的一些坑
Vi/vim editor
vulnhub之DC9
PostgreSQL notes
Parsing complex JSON in fluent
同花顺注册开户有没有什么风险?安全吗?
买股票通过中金证券经理的开户二维码开户资金是否安全?想开户炒股
宝藏又小众的覆盖物PBR多通道贴图素材网站分享
Introduction to dependency injection in SAP Spartacus
Homebrew installation in MacOS environment [email protected]
Icml2022 | neurotoxin: a lasting back door to federal learning
AI intelligent matting tool - hair can be seen
卷积神经网络(CNN)详解及TensorFlow2代码实现
会计要素包括哪些内容
用C#通过sql语句操作Sqlserver数据库教程
DAST black box vulnerability scanner part 5: vulnerability scanning engine and service capability
在哪家证券公司开户最方便最安全可靠
Operator介绍
SAP commerce cloud project Spartacus getting started
YuMinHong: New Oriental does not have a reversal of falling and turning over, destroying and rising again