编程介的小学生 2018-11-15 15:52 采纳率: 20.5%
浏览 573
已采纳

最佳路径选择,求一个算法大神来帮助下看看怎么做

Problem Description
As a cheap labor in a small company, LL has to ride back and forth between school and office every day. It is a tedious trip. So he want to design the most satisfactory riding route. After several day's experiment, he draw the simple map. It contains n*m areas. The school is in (0,0) while the office is in (n-1,m-1). He also record the scenery rank of each area A(i,j) and the time need to ride through each area B(i,j). ( For the start and end, A(0,0), B(0,0), A(n-1,m-1), B(n-1,m-1) are always 0. ) Now, LL defines the satisfactory degree of a round trip as follow:

                                   ∑{ A(i,j) | Area (i,j) is in the riding route (come or go). }

the satisfactory degree = ----------------------------------------------------------------------
∑{ B(i,j) | Area (i,j) is in the riding route (come or go). }

Attention: 1. LL doesn't want to make a detour. So, from school to office he only ride rightward or downward and from office to school only leftward or upward.
2. LL won't pass the same area in the whole round trip except the start and end.

Input
Each test case begins with two integers n,m ( 3<=n,m<=30 ), which is the size of the map. Then n lines follow, each contains m integers A(i,j). Another n lines follow, each contains m integers B(i,j). 1 <= A(i,j),B(i,j) <= 100.

Output
For each case, Output the maximal satisfactory degree he can get in a round trip.

Sample Input
3 3
0 1 2
3 4 5
6 7 0
0 7 6
5 4 3
2 1 0

Sample Output
13/11

  • 写回答

1条回答 默认 最新

  • threenewbee 2018-12-21 15:39
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波