当前位置:网站首页>数字三角形模型 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;
}
原创不易
转载请标明出处
如果对你有所帮助 别忘啦点赞支持哈
边栏推荐
- [untitled]
- [email protected] raspberry pie
- Redistemplate common collection instructions opsforvalue (II)
- Redis6 cluster setup
- MIT6.s081-2020 Lab2 System Calls
- [paper reading] nflowjs: synthetic negative data intensive anomaly detection based on robust learning
- H3C S5820V2_5830V2交换机IRF2堆叠后升级方法
- Hongliao Technology: how to quickly improve Tiktok store
- Linux regularly backs up MySQL database
- Station B, Master Liu Er - dataset and data loading
猜你喜欢

Yygh-11-timing statistics

HCIA复习

Rustdesk builds its own remote desktop relay server

Function of activation function

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

【课程笔记】编译原理
![[paper reading] nflowjs: synthetic negative data intensive anomaly detection based on robust learning](/img/9c/2753f68ecec3555aaca23800dada1e.png)
[paper reading] nflowjs: synthetic negative data intensive anomaly detection based on robust learning

Redis message queue
[email protected] raspberry pie"/>[email protected] raspberry pie

Station B Liu Erden - linear regression and gradient descent
随机推荐
Query the standard text code corresponding to a work center (s) in the production order
A master in the field of software architecture -- Reading Notes of the beauty of Architecture
Pay attention to the details of pytoch code, and it is easy to make mistakes
Company video accelerated playback
Analysis of grammar elements in turtle Library
P2802 go home
Network protocol model
【无标题】
ArcGIS application foundation 4 thematic map making
数学三大核心领域概述:几何
AUTOSAR从入门到精通番外篇(十)-嵌入式S19文件解析
Raised a kitten
SQLMAP使用教程(三)实战技巧二
What are the test sites for tunnel engineering?
Redis6 cluster setup
continue和break的区别与用法
Summary of data sets in intrusion detection field
Memory and stack related concepts
Eigen稀疏矩阵操作
[Thesis code] SML part code reading