Sphere Online Judge

SPOJ Problem Set (classical)

3931. Maximum Triangle Area

Problem code: MTRIAREA


Given n distinct points on a plane, your task is to find the triangle that have the maximum area, whose vertices are from the given points.




The input consists of several test cases. The first line of each test case contains an integer n, indicating the number of points on the plane. Each of the following n lines contains two integer xi and yi, indicating the ith points. The last line of the input is an integer −1, indicating the end of input, which should not be processed. You may assume that 1 ≤ n ≤ 50000 and −10^4 ≤ xi, yi ≤ 10^4 for all i = 1 . . . n.

Sample Input
3 4
2 6
2 7
2 6
3 9
2 0
8 0
6 5



For each test case, print a line containing the maximum area, which contains two digits after the decimal point. You may assume that there is always an answer which is greater than zero.

Sample output

Added by:~!(*(@*!@^&
Time limit:1s-5s
Source limit:50000B
Memory limit:256MB
Cluster: Pyramid (Intel Pentium III 733 MHz)
Languages:All except: ERL JS PERL 6
Resource:Pre Shanghai 2004

hide comments
2014-07-26 10:57:21 Naman Goyal
Don't use float, you'll get WA.
2014-06-13 17:57:17 hit_code
some more test case?
2012-11-16 07:10:37 :D
Yes, they seem to rule each other out. Well, strictly speaking 1 <= n <= 50000, doesn't require some n to be 1 or 2, but ranges shouldn't be that unnecessary invalid.
2012-11-16 03:13:50 uberness132
how can n < 3? "You may assume that 1 ≤ n ≤ 50000 " and "You may assume that there is always an answer which is greater than zero."
2010-11-24 09:46:44 Cong Liu
My algo is O(n) which I think should be right but not yet proofed.

Last edit: 2009-04-15 15:01:38
2010-11-24 09:46:44 [Trichromatic] XilinX
O(n^2)(Of course, with many optimizations) CAN get Accepted!

Last edit: 2009-03-26 03:01:49
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.