当前位置:网站首页>Digital triangle model acwing 1015 Picking flowers
Digital triangle model acwing 1015 Picking flowers
2022-07-06 06:12:00 【T_ Y_ F666】
Digital triangle model AcWing 1015. Picking flowers
Original link
Algorithm tags
DP linear DP
Ideas
Code
#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;
}
Originality is not easy.
Reprint please indicate the source
If it helps you Don't forget to praise and support
边栏推荐
- Luogu p1460 [usaco2.1] healthy Holstein cows
- 异常检测方法总结
- Grant Yu, build a web page you want from 0
- 黑猫带你学UFS协议第18篇:UFS如何配置逻辑单元(LU Management)
- A complete collection of necessary learning websites for office programmers
- Fault, error, failure of functional safety
- Amazon Engineer: eight important experiences I learned in my career
- 【C语言】字符串左旋
- Basic knowledge of error
- Company video accelerated playback
猜你喜欢
Hypothesis testing learning notes
[untitled]
Sqlmap tutorial (III) practical skills II
【Tera Term】黑猫带你学TTL脚本——嵌入式开发中串口自动化神技能
Understanding of processes and threads
Seven imperceptible truths in software testing
Network protocol model
Application du Groupe Li dans gtsam
Buuctf-[bjdctf2020]zjctf, but so (xiaoyute detailed explanation)
技术分享 | 常见接口协议解析
随机推荐
【eolink】PC客户端安装
SQLMAP使用教程(三)实战技巧二
GTSAM中李群的运用
【LeetCode】Day96-第一个唯一字符&赎金信&字母异位词
Cognitive introspection
Raised a kitten
Title 1093: character reverse order
How to recover Huawei router's forgotten password
Manhattan distance and Manhattan rectangle - print back font matrix
Manhattan distance sum - print diamond
How Huawei routers configure static routes
GTSAM中ISAM2和IncrementalFixedLagSmoother说明
Function of activation function
Overview of three core areas of Mathematics: algebra
【无App Push 通用测试方案
Arrays and collections
養了只小猫咪
properties文件
Clock in during winter vacation
Dynamic programming -- knapsack problem