当前位置:网站首页>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;
}
边栏推荐
- Practice of traffic recording and playback in vivo
- I2C 子系统(二):I3C spec
- I2C subsystem (III): I2C driver
- C语言初阶-指针详解-庖丁解牛篇
- [translation] modern application load balancing with centralized control plane
- ASP. Net core 6 framework unveiling example demonstration [02]: application development based on routing, MVC and grpc
- Didi programmers are despised by relatives: an annual salary of 800000 is not as good as two teachers
- 从C到Capable-----利用指针作为函数参数求字符串是否为回文字符
- Andwhere multiple or query ORM conditions in yii2
- How to return ordered keys after counter counts the quantity
猜你喜欢
随机推荐
搭建私有云盘 cloudreve
[fluent] listview list (map method description of list set | vertical list | horizontal list | code example)
tensorflow转pytorch笔记;tf.gather_nd(x,y)转pytorch
Random Shuffle attention
Thunderbolt Chrome extension caused the data returned by the server JS parsing page data exception
Source code analysis | resource loading resources
Today, it's time to copy the bottom!
Deep reinforcement learning for intelligent transportation systems: a survey paper reading notes
Unity3d human skin real time rendering real simulated human skin real time rendering "suggestions collection"
Interview stereotyped version
How to use asp Net MVC identity 2 change password authentication- How To Change Password Validation in ASP. Net MVC Identity 2?
左值右指解释的比较好的
HTB-Devel
从C到Capable-----利用指针作为函数参数求字符串是否为回文字符
2022-2028 global splicing display industry research and trend analysis report
SQL Server Query spécifie la structure de la table
I2C 子系統(四):I2C debug
[fluent] futurebuilder asynchronous programming (futurebuilder construction method | asyncsnapshot asynchronous calculation)
From C to capable -- use the pointer as a function parameter to find out whether the string is a palindrome character
[shutter] setup of shutter development environment (supplement the latest information | the latest installation tutorial on August 25, 2021)





