当前位置:网站首页>力扣------网格中的最小路径代价
力扣------网格中的最小路径代价
2022-07-03 02:48:00 【qq_37760746】

int minPathCost(int** grid, int gridSize, int* gridColSize, int** moveCost, int moveCostSize, int* moveCostColSize){
int dp[gridSize][gridColSize[0]];
for(int a=0;a<gridSize;a++){
for(int b=0;b<gridColSize[0];b++){
dp[a][b]=grid[a][b];
}
}
for(int a=1;a<gridSize;a++){
for(int b=0;b<gridColSize[0];b++){
int min=100000;
for(int c=0;c<gridColSize[0];c++){
if(min>dp[a-1][c]+dp[a][b]+moveCost[grid[a-1][c]][b]){
min=dp[a-1][c]+dp[a][b]+moveCost[grid[a-1][c]][b];
}
}
dp[a][b]=min;
}
}
int min=100000;
for(int a=0;a<gridColSize[0];a++){
if(min>dp[gridSize-1][a]){
min=dp[gridSize-1][a];
}
}
return min;
}
边栏推荐
- Andwhere multiple or query ORM conditions in yii2
- The process of connecting MySQL with docker
- 【翻译】后台项目加入了CNCF孵化器
- Error when installing MySQL in Linux: starting mysql The server quit without updating PID file ([FAILED]al/mysql/data/l.pid
- 《MATLAB 神经网络43个案例分析》:第43章 神经网络高效编程技巧——基于MATLAB R2012b新版本特性的探讨
- SQL statement
- What does "where 1=1" mean
- Principle and application of database
- Joking about Domain Driven Design (III) -- Dilemma
- Concrete CMS vulnerability
猜你喜欢

HTB-Devel

random shuffle注意

Xiaodi notes

I2C 子系统(一):I2C spec

【翻译】后台项目加入了CNCF孵化器

从C到Capable-----利用指针作为函数参数求字符串是否为回文字符

From C to capable -- use the pointer as a function parameter to find out whether the string is a palindrome character

Three. JS local environment setup

sql server数据库添加 mdf数据库文件,遇到的报错

Practice of traffic recording and playback in vivo
随机推荐
How to change the panet layer in yolov5 to bifpn
[Hcia]No.15 Vlan间通信
函数栈帧的创建与销毁
Gbase 8C create user / role example 2
The difference between left value and right value in C language
Classes and objects - initialization and cleanup of objects - constructor call rules
tensor中的append应该如何实现
左值右指解释的比较好的
【Flutter】shared_ Preferences local storage (introduction | install the shared_preferences plug-in | use the shared_preferences process)
[translation] the background project has joined the CNCF incubator
I2C 子系统(三):I2C Driver
Simple understanding of SVG
Pytest (6) -fixture (Firmware)
xiaodi-笔记
Gbase 8C trigger (I)
Build a private cloud disk cloudrev
I2C 子系统(一):I2C spec
一文带你了解 ZigBee
Gbase 8C function / stored procedure parameters (I)
I2C 子系統(四):I2C debug