当前位置:网站首页>Digital triangle model acwing 1018 Minimum toll
Digital triangle model acwing 1018 Minimum toll
2022-07-06 20:08:00 【T_ Y_ F666】
Digital triangle model AcWing 1018. Minimum tolls
Original link
Algorithm tags
DP linear DP
Ideas
From the meaning of the title , Time spent should be less than (2N−1) , So you can't go back , Similar to the problem of picking peanuts .
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, INF = 0x3f3f3f3f;
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 n=read();
rep(i, 1, n+1){
rep(j, 1, n+1){
a[i][j]=read();
}
}
rep(i, 1, n+1){
rep(j, 1, n+1){
if(i==1&&j==1){
f[i][j]=a[i][j];
}else{
f[i][j]=INF;
if(i>1){
f[i][j]=min(f[i][j], f[i-1][j]+a[i][j]);
}
if(j>1){
f[i][j]=min(f[i][j], f[i][j-1]+a[i][j]);
}
}
}
}
printf("%lld", f[n][n]);
return 0;
}
Originality is not easy.
Reprint please indicate the source
If it helps you Don't forget to praise and support 
边栏推荐
- RT-Thread 组件 FinSH 使用时遇到的问题
- 数据的同步为每个站点创建触发器同步表
- Tencent T2 Daniel explained in person and doubled his job hopping salary
- [calculating emotion and thought] floor sweeper, typist, information panic and Oppenheimer
- 颜色(color)转换为三刺激值(r/g/b)(干股)
- [cloud lesson] EI lesson 47 Mrs offline data analysis - processing OBS data through Flink
- 深入浅出,面试突击版
- Tencent byte Alibaba Xiaomi jd.com offer got a soft hand, and the teacher said it was great
- Cf960g - bandit Blues (type I Stirling number +ogf)
- 信息系统项目管理师---第八章 项目质量管理
猜你喜欢

Social recruitment interview experience, 2022 latest Android high-frequency selected interview questions sharing
腾讯字节等大厂面试真题汇总,网易架构师深入讲解Android开发
![[calculating emotion and thought] floor sweeper, typist, information panic and Oppenheimer](/img/8c/afb90128e7a523bbee4c6c4166363f.png)
[calculating emotion and thought] floor sweeper, typist, information panic and Oppenheimer

Tencent byte Alibaba Xiaomi jd.com offer got a soft hand, and the teacher said it was great

A5000 vgpu display mode switching

5. 無線體內納米網:十大“可行嗎?”問題

Redisson bug analysis

Tencent T3 Daniel will teach you hand-in-hand, the internal information of the factory

New generation garbage collector ZGC

深入浅出,面试突击版
随机推荐
22-07-05 upload of qiniu cloud storage pictures and user avatars
Crawler (14) - scrape redis distributed crawler (1) | detailed explanation
Example of applying fonts to flutter
颜色(color)转换为三刺激值(r/g/b)(干股)
Microservice architecture debate between radical technologists vs Project conservatives
POJ3617 Best Cow Line 馋
An East SMS login resurrection installation and deployment tutorial
Poj3617 best cow line
JVM_常见【面试题】
In simple terms, interview surprise Edition
js实现力扣71题简化路径
AsyncHandler
[Yann Lecun likes the red stone neural network made by minecraft]
What happened to the kernel after malloc() was transferred? Attached malloc () and free () implementation source
Leetcode 30. Concatenate substrings of all words
腾讯T3大牛手把手教你,大厂内部资料
小微企业难做账?智能代账小工具快用起来
Database specific interpretation of paradigm
HDU 1026 Ignatius and the Princess I 迷宫范围内的搜索剪枝问题
[network planning] Chapter 3 data link layer (4) LAN, Ethernet, WLAN, VLAN