当前位置:网站首页>力扣------网格中的最小路径代价
力扣------网格中的最小路径代价
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;
}
边栏推荐
- leetcode540
- [Fuhan 6630 encodes and stores videos, and uses RTSP server and timestamp synchronization to realize VLC viewing videos]
- Introduction to cron expression
- Strategy application of Dameng database
- Kubernetes family container housekeeper pod online Q & A?
- [translation] modern application load balancing with centralized control plane
- js根据树结构查找某个节点的下面的所有父节点或者子节点
- C语言中左值和右值的区别
- [principles of multithreading and high concurrency: 1_cpu multi-level cache model]
- [translation] the background project has joined the CNCF incubator
猜你喜欢

Joking about Domain Driven Design (III) -- Dilemma

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

内存泄漏工具VLD安装及使用

MATLAB小技巧(24)RBF,GRNN,PNN-神经网络

Basic operation of binary tree (C language version)

Error invalid bound statement (not found): com ruoyi. stock. mapper. StockDetailMapper. XXXX solution

Check log4j problems using stain analysis

vfork执行时出现Segmentation fault

Kubernetes family container housekeeper pod online Q & A?

Mathematical statistics -- Sampling and sampling distribution
随机推荐
What does "where 1=1" mean
【富瀚6630编码存录像,用rtsp服务器及时间戳同步实现vlc观看录像】
Gbase 8C trigger (I)
Your family must be very poor if you fight like this!
C语言初阶-指针详解-庖丁解牛篇
[fluent] future asynchronous programming (introduction | then method | exception capture | async, await keywords | whencomplete method | timeout method)
Global and Chinese ammonium dimolybdate market in-depth analysis and prospect risk prediction report 2022 Edition
Why choose a frame? What frame to choose
Didi programmers are despised by relatives: an annual salary of 800000 is not as good as two teachers
HTB-Devel
Classes and objects - initialization and cleanup of objects - constructor call rules
Concrete CMS vulnerability
The solution of "the required function is not supported" in win10 remote desktop connection is to modify the Registry [easy to understand]
Joking about Domain Driven Design (III) -- Dilemma
Packing and unpacking of JS
[translation] flux is safe. Gain more confidence through fuzzy processing
[Fuhan 6630 encodes and stores videos, and uses RTSP server and timestamp synchronization to realize VLC viewing videos]
[hcia]no.15 communication between VLANs
Gbase 8C system table PG_ attribute
Basic operation of binary tree (C language version)