当前位置:网站首页>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 */
边栏推荐
- How to enable Hana cloud service on SAP BTP platform
- leetcode:6103. Delete the minimum score of the edge from the tree [DFS + connected component + value record of the subgraph]
- 在线协作文档综合评测 :Notion、FlowUs、Wolai、飞书、语雀、微软 Office、谷歌文档、金山文档、腾讯文档、石墨文档、Dropbox Paper、坚果云文档、百度网盘在线文档
- Is this a bug? Whether the randomly filled letters can be closed
- SAP Spartacus 默认路由配置的工作原理
- The network connection is disconnected. Please refresh and try again
- Simple Lianliankan games based on QT
- Is there any risk for flush to register and open an account? Is it safe?
- Application and Optimization Practice of 100 million level monthly live national karaoke feed service in Tencent cloud mongodb
- fastadmin极光推送发送消息的时候registration_id多个用逗号分割后无效
猜你喜欢
![[LeetCode]-链表-2](/img/f7/9d4b01285fd6f7fa9f3431985111b0.png)
[LeetCode]-链表-2

茂莱光学科创板上市:拟募资4亿 范一与范浩兄弟为实控人

Leetcode(452)——用最少数量的箭引爆气球

CVPR 2022 | 美团技术团队精选论文解读

会计要素包括哪些内容

Kdd2022 𞓜 unified session recommendation system based on knowledge enhancement prompt learning

财务费用分析怎么分析

VB.net类库,获取屏幕内鼠标下的颜色(进阶——3)

Convolutional neural network (CNN) explanation and tensorflow2 code implementation
![leetcode:1567. Length of the longest subarray whose product is a positive number [dp[i] indicates the maximum length ending with I]](/img/a4/c5c31de7a0a3b34a188bfec0b5d184.png)
leetcode:1567. Length of the longest subarray whose product is a positive number [dp[i] indicates the maximum length ending with I]
随机推荐
VB.net类库,获取屏幕内鼠标下的颜色(进阶——3)
AI intelligent matting tool - hair can be seen
Netease Yunxin officially joined the smart hospital branch of China Medical Equipment Association to accelerate the construction of smart hospitals across the country
MacOS环境下使用HomeBrew安装[email protected]
在Flutter中解析复杂的JSON
360 mobile assistant is the first to access the app signature service system to help distribute privacy and security
Final part of web crawler: send directional messages to 100000 Netease cloud users
线性模型LN、单神经网络SNN、深度神经网络DNN与CNN测试对比
KDD2022 | 基于知识增强提示学习的统一会话推荐系统
Which platform is the safest for buying stocks and opening accounts? Ask for sharing
leetcode:710. Random numbers in the blacklist [mapping thinking]
网络爬虫终篇:向10万级网易云用户发送定向消息
中金证券经理给的开户二维码办理股票开户安全吗?我想开个户
Chapter 2 construction of self defined corpus
会计要素包括哪些内容
y48.第三章 Kubernetes从入门到精通 -- Pod的状态和探针(二一)
How SAP Spartacus default routing configuration works
leetcode:6103. 从树中删除边的最小分数【dfs + 联通分量 + 子图的值记录】
Web crawler 2: crawl the user ID and home page address of Netease cloud music reviews
The importance of using fonts correctly in DataWindow