当前位置:网站首页>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;
}
边栏推荐
- Apple releases MacOS 11.6.4 update: mainly security fixes
- 左连接,内连接
- xiaodi-笔记
- SQL server queries the table structure of the specified table
- [C语言]给账号密码进行MD5加密
- Check log4j problems using stain analysis
- Andwhere multiple or query ORM conditions in yii2
- [leectode 2022.2.15] lucky numbers in the matrix
- tensor中的append应该如何实现
- Deep learning: multi-layer perceptron and XOR problem (pytoch Implementation)
猜你喜欢
随机推荐
Source code analysis | resource loading resources
The difference between left value and right value in C language
Random Shuffle attention
[fluent] futurebuilder asynchronous programming (futurebuilder construction method | asyncsnapshot asynchronous calculation)
Linear rectification function relu and its variants in deep learning activation function
HW-初始准备
I2C 子系統(四):I2C debug
Serious security vulnerabilities reported by moxa mxview network management software
Super easy to use logzero
I2C subsystem (III): I2C driver
The core idea of performance optimization, dry goods sharing
Deep learning: multi-layer perceptron and XOR problem (pytoch Implementation)
Deep Reinforcement Learning for Intelligent Transportation Systems: A Survey 论文阅读笔记
Classes and objects - initialization and cleanup of objects - constructor call rules
当lambda没有输入时,是何含义?
From C to capable -- use the pointer as a function parameter to find out whether the string is a palindrome character
JMeter performance test JDBC request (query database to obtain database data) use "suggestions collection"
[principles of multithreading and high concurrency: 1_cpu multi-level cache model]
I2C 子系统(三):I2C Driver
TCP 三次握手和四次挥手机制,TCP为什么要三次握手和四次挥手,TCP 连接建立失败处理机制