当前位置:网站首页>数字三角形模型 AcWing 1015. 摘花生
数字三角形模型 AcWing 1015. 摘花生
2022-07-06 05:58:00 【T_Y_F666】
数字三角形模型 AcWing 1015. 摘花生
原题链接
算法标签
DP 线性DP
思路

代码
#include<bits/stdc++.h>
#define int long long
#define rep(i, a, b) for(int i=a;i<b;++i)
#define Rep(i, a, b) for(int i=a;i>=b;--i)
using namespace std;
const int N = 105;
int f[N][N], a[N][N];
inline int read(){
int s=0,w=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;
}
void put(int x) {
if(x<0) putchar('-'),x=-x;
if(x>=10) put(x/10);
putchar(x%10^48);
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t=read();
while(t--){
int r=read(), c=read();
rep(i, 1, r+1){
rep(j, 1, c+1){
a[i][j]=read();
}
}
rep(i, 1, r+1){
rep(j, 1, c+1){
f[i][j]=max(f[i-1][j], f[i][j-1])+a[i][j];
}
}
printf("%lld\n", f[r][c]);
}
return 0;
}
原创不易
转载请标明出处
如果对你有所帮助 别忘啦点赞支持哈
边栏推荐
- 数学三大核心领域概述:几何
- Station B, Mr. Liu Er - multiple logistic regression, structure 7
- 请求转发与重定向
- 进程和线程
- IPv6 comprehensive experiment
- Download, install and use NVM of node, and related use of node and NRM
- 华为路由器如何配置静态路由
- Processes and threads
- Web service connector: Servlet
- Pay attention to the details of pytoch code, and it is easy to make mistakes
猜你喜欢

VINS-Mono: A Robust and Versatile Monocular Visual-Inertial State Estimator

J'ai un chaton.

Leetcode 701 insertion operation in binary search tree -- recursive method and iterative method

Redis message queue
![[Jiudu OJ 08] simple search x](/img/a7/12a00c5d1db2deb064ff5f2e83dc58.jpg)
[Jiudu OJ 08] simple search x

P2802 go home

LTE CSFB process

What are the test sites for tunnel engineering?

Construction of yolox based on paste framework

假设检验学习笔记
随机推荐
Sequoiadb Lake warehouse integrated distributed database, June 2022 issue
First knowledge database
MIT6.s081-2020 Lab2 System Calls
Function of contenttype
华为路由器如何配置静态路由
Luogu p1460 [usaco2.1] healthy Holstein cows
My 2021
Huawei BFD configuration specification
Baidu online AI competition - image processing challenge: the 8th program of handwriting erasure
Gtest之TEST宏的用法
VINS-Mono: A Robust and Versatile Monocular Visual-Inertial State Estimator
Report on the competition status and investment decision recommendations of Guangxi hospital industry in China from 2022 to 2028
Raised a kitten
Classes and objects (I) detailed explanation of this pointer
The usage and difference between strlen and sizeof
[email protected] raspberry pie
Interface test: what are the components of the URL in fiddler
Web service connector: Servlet
SQLMAP使用教程(三)实战技巧二
A complete collection of necessary learning websites for office programmers