当前位置:网站首页>数字三角形模型 AcWing 1015. 摘花生
数字三角形模型 AcWing 1015. 摘花生
2022-07-27 10:35: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;
}
原创不易
转载请标明出处
如果对你有所帮助 别忘啦点赞支持哈
边栏推荐
- IO流_字符流、IO流小结、IO流案例总结
- ethereum rpc
- IO stream_ Character stream, IO stream summary, IO stream case summary
- FAQs of "relay chain" and "dot" in Poka ecosystem
- Miscellaneous records of Finance
- Today's code farmer girl learned notes about event operation and ref attribute, and did the practice of form two-way binding
- 最短移动距离和形态复合体的熵
- Caused by:org.gradle.api.internal.plugins . PluginApplicationException: Failed to apply plugin
- ACM warm-up Exercise 2 in 2022 summer vacation (summary)
- Opengauss kernel analysis - statistics and row count estimation
猜你喜欢

JVM judges that the object is dead, and practices verify GC recycling

栈 AcWing 3302. 表达式求值

img src为空或者src不存在,图片出现白色边框

Opengauss kernel analysis - statistics and row count estimation

Antd table+checkbox default value display

Longest ascending subsequence model acwing 1010. Interceptor missile

tensorflow运行报错解决方法

BeautifulSoup的使用

SQL Server2000 database error

What is the mystery of the gate of the meta universe?
随机推荐
Application scenarios, key technologies and network architecture of communication perception integration
Based on the open source stream batch integrated data synchronization engine Chunjun data restore DDL parsing module actual combat sharing
最长上升子序列模型 AcWing 1017. 怪盗基德的滑翔翼
Thank you for your likes and attention
发动机悬置系统冲击仿真-瞬时模态动态分析与响应谱分析
熵与形态的非递进现象
NFT leaderboard -nft real offer latest address: NFT leaderboard.com
图片中非0值的数量对分类的影响
Caused by:org.gradle.api.internal.plugins . PluginApplicationException: Failed to apply plugin
最长上升子序列模型 AcWing 1012. 友好城市
博弈论 AcWing 894. 拆分-Nim游戏
Local and overall differences between emergence and morphology
Why is the data service API the standard configuration of the data midrange when we take the last mile of the data midrange?
Longest ascending subsequence model acwing 1012. Sister Cities
IO流_字符流、IO流小结、IO流案例总结
A verification test of the relationship between iteration number and entropy
10 complete half of the questions
数字三角形模型 AcWing 275. 传纸条
Derivation of the detailed expansion sto overlap integrals
pyquery 的使用