当前位置:网站首页>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 */
边栏推荐
- Fastadmin Aurora push send message registration_ Multiple IDs are invalid after being separated by commas
- Flutter 中 ValueNotifier<List<T>> 监听问题解决
- 宝藏又小众的覆盖物PBR多通道贴图素材网站分享
- 花店橱窗布置【动态规划】
- Y48. Chapter III kubernetes from introduction to mastery -- pod status and probe (21)
- VB.net类库(进阶——2 重载)
- Implementation of collaborative filtering evolution version neuralcf and tensorflow2
- 十大券商注册开户有没有什么风险?安全吗?
- 基于启发式搜索的一字棋
- 财务费用分析怎么分析
猜你喜欢

【图像处理基础】基于matlab GUI图像曲线调整系统【含Matlab源码 1923期】

In 2022, where will the medium and light-weight games go?

Parsing complex JSON in fluent

财务费用分析怎么分析

Listing of maolaiguang discipline on the Innovation Board: it is planned to raise 400million yuan. Fanyi and fanhao brothers are the actual controllers

DAST 黑盒漏洞扫描器 第五篇:漏洞扫描引擎与服务能力

Simple Lianliankan games based on QT

在Flutter中解析复杂的JSON

vulnhub之dc8

线性模型LN、单神经网络SNN、深度神经网络DNN与CNN测试对比
随机推荐
Is there any risk in registering and opening an account for stock speculation? Is it safe?
lotus configurations
[LeetCode]-链表-2
Android mediacodec hard coded H264 file (four), ByteDance Android interview
How to enable Hana cloud service on SAP BTP platform
ICML2022 | Neurotoxin:联邦学习的持久后门
API管理之利剑 -- Eolink
Using C to operate SQLSERVER database through SQL statement tutorial
random_ normal_ Initializer uses
What are the accounting elements
SAP commerce cloud project Spartacus getting started
Common concurrent testing tools and pressure testing methods
Redis + Guava 本地缓存 API 组合,性能炸裂!
YOLOv6:又快又准的目标检测框架开源啦
curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection
基于启发式搜索的一字棋
Shiniman household sprint A shares: annual revenue of nearly 1.2 billion red star Macalline and incredibly home are shareholders
vulnhub之dc8
leetcode:152. Product maximum subarray [consider DP of two dimensions]
【protobuf 】protobuf 昇級後帶來的一些坑