当前位置:网站首页>数字三角形模型 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;
}
原创不易
转载请标明出处
如果对你有所帮助 别忘啦点赞支持哈
边栏推荐
- CoDeSys note 2: set coil and reset coil
- How to recover Huawei router's forgotten password
- [email protected] raspberry pie
- [Jiudu OJ 08] simple search x
- Migrate Infones to stm32
- J'ai un chaton.
- A master in the field of software architecture -- Reading Notes of the beauty of Architecture
- 单元测试的意义
- [paper reading] nflowjs: synthetic negative data intensive anomaly detection based on robust learning
- 公司視頻加速播放
猜你喜欢
误差的基本知识
功能安全之故障(fault),错误(error),失效(failure)
Hongliao Technology: how to quickly improve Tiktok store
Novice entry SCM must understand those things
Sequoiadb Lake warehouse integrated distributed database, June 2022 issue
【论文代码】SML部分代码阅读
假设检验学习笔记
Baidu online AI competition - image processing challenge: the 8th program of handwriting erasure
Memory and stack related concepts
请求转发与重定向
随机推荐
How to recover Huawei router's forgotten password
嵌入式面试题(四、常见算法)
华为路由器忘记密码怎么恢复
Gtest之TEST宏的用法
CoDeSys note 2: set coil and reset coil
A master in the field of software architecture -- Reading Notes of the beauty of Architecture
Rustdesk builds its own remote desktop relay server
授予渔,从0开始搭建一个自己想要的网页
Arrays and collections
Grant Yu, build a web page you want from 0
SQLMAP使用教程(三)实战技巧二
GTSAM中李群的运用
The usage and difference between strlen and sizeof
About PHP startup, mongodb cannot find the specified module
Sqlmap tutorial (III) practical skills II
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
[ram IP] introduction and experiment of ram IP core
【论文代码】SML部分代码阅读
Function of activation function
[string] palindrome string of codeup