HCN3D - The God-land

How great is our God! To show the respect for God, Bethlehem people decide to build a large area for memorial called "The God-land". There's a story that God used to visit N areas which is rectangles having edges paralell to the axises, described by the co-ordinate of a pair of opposite vertices: Xi1, Yi1, Xi2, Yi2 (any two of them may have no common point, one common vertex or one common edge at most); on which of them there is a kind of grass called Ci. People there want to build the God-land which is also a rectangle having edges parallel to the axises, putting on area(s) mentioned above, having a same kind of grass and having the maximum area! Help them to find the God-land before this Christmas!

Input

- The first line contains N.
- Next N line(s), each line contains Xi1, Yi1, Xi2, Yi2 and Ci describing the ith area to which God used to visit.

Output

- The maximum area found.

Sample

Input:
5
1 1 3 3 1
3 1 5 3 1
1 4 3 6 1
3 4 5 6 1
0 3 6 4 2

Output:
8

Input:
5
5 5 6 6 22
3 4 6 5 22
6 3 7 6 22
5 6 8 7 22
4 5 5 8 22

Output:
9

Limitations

- N ≤ 2500.
- 0 ≤ Xi1, Yi1, Xi2, Yi2 ≤ 109.
- 1 ≤ Ci ≤ 100.

Sorry for my bad English!^_^ Please comment for a better translation ;)


Được gửi lên bởi:AnhDQ
Ngày:2009-05-02
Thời gian chạy:0.200s-0.800s
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:AnhDQ (re-coverd)

hide comments
2009-05-04 17:03:51 AnhDQ
Test và Timelimit đã ổn ;)
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.