当前位置:网站首页>数字三角形模型 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;
}
原创不易
转载请标明出处
如果对你有所帮助 别忘啦点赞支持哈
边栏推荐
- Report on the competition status and investment decision recommendations of Guangxi hospital industry in China from 2022 to 2028
- Construction of yolox based on paste framework
- 假设检验学习笔记
- As3013 fire endurance test of cable distribution system
- Yygh-11-timing statistics
- Luogu p1460 [usaco2.1] healthy Holstein cows
- Network protocol model
- 嵌入式面试题(一:进程与线程)
- Accélération de la lecture vidéo de l'entreprise
- Leetcode 701 insertion operation in binary search tree -- recursive method and iterative method
猜你喜欢
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
Jushan database appears again in the gold fair to jointly build a new era of digital economy
Rustdesk builds its own remote desktop relay server
[experience] install Visio on win11
Processes and threads
IP day 16 VLAN MPLS configuration
Web service connector: Servlet
LAN communication process in the same network segment
[email protected] raspberry pie"/>
[email protected] raspberry pie
[Jiudu OJ 08] simple search x
随机推荐
VINS-Mono: A Robust and Versatile Monocular Visual-Inertial State Estimator
Accélération de la lecture vidéo de l'entreprise
High quality coding tool clion
Sequoiadb Lake warehouse integrated distributed database, June 2022 issue
【LeetCode】Day96-第一个唯一字符&赎金信&字母异位词
Software test interview questions - Test Type
Summary of data sets in intrusion detection field
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
[experience] when ultralso makes a startup disk, there is an error: the disk / image capacity is too small
HCIA review
Cognitive introspection
如何在业务代码中使用 ThinkPHP5.1 封装的容器内反射方法
[experience] install Visio on win11
Baidu online AI competition - image processing challenge: the 8th program of handwriting erasure
Function of activation function
P2802 go home
continue和break的区别与用法
LTE CSFB process
[ram IP] introduction and experiment of ram IP core