当前位置:网站首页>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;
}
边栏推荐
- Getting started | jetpack hilt dependency injection framework
- Reset or clear NET MemoryStream - Reset or Clear . NET MemoryStream
- Andwhere multiple or query ORM conditions in yii2
- How to select the minimum and maximum values of columns in the data table- How to select min and max values of a column in a datatable?
- 你真的懂继电器吗?
- A2L file parsing based on CAN bus (2)
- How to change the panet layer in yolov5 to bifpn
- Hcip137-147 title + analysis
- ASP. Net core 6 framework unveiling example demonstration [02]: application development based on routing, MVC and grpc
- The core idea of performance optimization, dry goods sharing
猜你喜欢
![[Hcia]No.15 Vlan间通信](/img/59/a467c5920cbccb72040f39f719d701.jpg)
[Hcia]No.15 Vlan间通信

Deep reinforcement learning for intelligent transportation systems: a survey paper reading notes

Choose it when you decide

Yiwen takes you to know ZigBee

The process of connecting MySQL with docker

Didi programmers are despised by relatives: an annual salary of 800000 is not as good as two teachers

HTB-Devel

I2C subsystem (IV): I2C debug

C语言初阶-指针详解-庖丁解牛篇

【翻译】后台项目加入了CNCF孵化器
随机推荐
Add automatic model generation function to hade
SQL Server Query spécifie la structure de la table
I2C subsystem (II): I3C spec
[Fuhan 6630 encodes and stores videos, and uses RTSP server and timestamp synchronization to realize VLC viewing videos]
Baidu map - surrounding search
Can netstat still play like this?
Mathematical statistics -- Sampling and sampling distribution
Kubernetes family container housekeeper pod online Q & A?
Check log4j problems using stain analysis
[shutter] bottom navigation bar page frame (bottomnavigationbar bottom navigation bar | pageview sliding page | bottom navigation and sliding page associated operation)
Didi programmers are despised by relatives: an annual salary of 800000 is not as good as two teachers
Pytest (6) -fixture (Firmware)
Introduction to cron expression
ASP. Net core 6 framework unveiling example demonstration [02]: application development based on routing, MVC and grpc
HTB-Devel
The left value and the right finger explain better
Getting started | jetpack hilt dependency injection framework
vfork执行时出现Segmentation fault
How to return ordered keys after counter counts the quantity
Super easy to use logzero