F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

The best riding route

Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 206    Accepted Submission(s): 13


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
 

Hint

The best riding route is (0,0)->(1,0)->(2,0)->(2,1)->(2,2)->(1,2)->(1,1)->(0,1)->(0,0).
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-11 13:12:28, Gzip enabled