Nộp bài | Các bài nộp | Làm tốt nhất | Về danh sách bài |
BLAND - Exchanging Land for a Fan |
English | Vietnamese |
The landlord has a rectangular land divided into a grid of M rows and N columns. The rows are numbered from the top to the bottom starting from 1, and the columns are numbered from the left to the right starting from 1. The intersection between the ith row and the jth column (i=1..M,j=1..N) has a height of hij. The landlord has offered to exchange his land for Bom's magic fan. Here's the condition of the offer:
- Bom can pick two sub-pieces of land (one for housing and one for gardening). Both pieces should have rectangular shape and contain a whole number of cells.
- Each piece should have its height difference not exceeding K, i.e. the difference between its highest cell and its lowest cell does not exceed k.
- The two pieces should not overlap each other (though they can be in contact).
- Please help Bom to pick the two pieces of land satisfying the above conditions and have the largest sum of areas.
Input
- The first line contains three integers M, N and K (M,N≤300).
- Each line in the next M lines contains N integers hij describing the land.(K,|hij|<109)
Output
A single number that is the largest possible sum of areas of Bom's two pieces of land.
Example
Input
3 4 0
1 2 3 1
1 9 9 1
2 2 2 2
Output
6
Note: There are 50% test cases in which m,n≤50.
Được gửi lên bởi: | Jimmy |
Ngày: | 2009-07-21 |
Thời gian chạy: | 0.200s-1s |
Giới hạn mã nguồn: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Ngôn ngữ cho phép: | Tất cả ngoại trừ: ERL GOSU JS-RHINO NODEJS PERL6 PYPY RUST SED VB.NET |
Nguồn bài: | VNOI Marathon 2009 Round 3 Problem Setter: Đỗ Đức Đông |
hide comments
2020-06-27 13:54:32
Tham khảo: Code: http://megaurl.in/yH4X53j |
|
2018-03-14 11:37:46
2 buổi chiều vẫn k ăn thua. nhọc... |
|
2017-11-24 02:17:00
nhật hào sạch |
|
2017-11-18 02:02:03
bfs đc ko nhỉ ??? |
|
2017-09-04 10:20:13
from Dinh Truong Lam trau cung ac ^^ |
|
2016-09-27 03:17:13
Code: http://shink.in/lgQGv |
|
2016-06-20 04:24:55
lần nào làm deque cũng sub đến tê liệt Last edit: 2016-06-21 12:10:38 |
|
2016-01-31 16:04:30 Nguyễn Thành Nhân
ez |
|
2015-10-27 19:47:31
Blog Thuật toán SPOJ hy vọng giúp được cho mọi người : http://www.oni.vn/uR57W |
|
2013-06-09 19:06:12 Cottontail Tee
time chặt quá X_X |