当前位置:网站首页>Force deduction ----- the minimum path cost in the grid
Force deduction ----- the minimum path cost in the grid
2022-07-03 02:53:00 【qq_ thirty-seven million seven hundred and sixty thousand seven】

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;
}
边栏推荐
- I2C subsystem (III): I2C driver
- 用docker 连接mysql的过程
- Privatization lightweight continuous integration deployment scheme -- 01 environment configuration (Part 2)
- 内存泄漏工具VLD安装及使用
- As a leader, how to control the code version and demand development when the epidemic comes| Community essay solicitation
- Super easy to use logzero
- Matlab tips (24) RBF, GRNN, PNN neural network
- 处理数据集,使用LabelEncoder将所有id转换为从0开始
- 力扣------网格中的最小路径代价
- Cancer biopsy instruments and kits - market status and future development trends
猜你喜欢
随机推荐
What is the way out for children from poor families?
Add automatic model generation function to hade
C language beginner level - pointer explanation - paoding jieniu chapter
Counter统计数量后,如何返回有序的key
What does "where 1=1" mean
[flutter] example of asynchronous programming code between future and futurebuilder (futurebuilder constructor setting | handling flutter Chinese garbled | complete code example)
TCP 三次握手和四次挥手机制,TCP为什么要三次握手和四次挥手,TCP 连接建立失败处理机制
疫情当头,作为Leader如何进行代码版本和需求开发管控?| 社区征文
Cron表达式介绍
Deep reinforcement learning for intelligent transportation systems: a survey paper reading notes
Update and return document in mongodb - update and return document in mongodb
xiaodi-笔记
2022-2028 global splicing display industry research and trend analysis report
C语言初阶-指针详解-庖丁解牛篇
SQL Server Query spécifie la structure de la table
怎么将yolov5中的PANet层改为BiFPN
[shutter] bottom navigation bar page frame (bottomnavigationbar bottom navigation bar | pageview sliding page | bottom navigation and sliding page associated operation)
[translation] the background project has joined the CNCF incubator
[C language] MD5 encryption for account password
JS finds all the parent nodes or child nodes under a node according to the tree structure









