add new solutions

This commit is contained in:
kanna5 2026-01-05 16:48:03 +09:00
parent ca24d0a56a
commit 0c73608ce5
Signed by: kkyy
GPG key ID: 06332F3965E9B0CF
36 changed files with 791 additions and 0 deletions

View file

@ -0,0 +1,24 @@
package q812
func area2(a, b []int) float64 {
return float64((a[1]+b[1])*(b[0]-a[0])) / 2
}
func largestTriangleArea(points [][]int) float64 {
var maxArea float64
for a := 0; a < len(points)-2; a++ {
for b := a + 1; b < len(points)-1; b++ {
for c := b + 1; c < len(points); c++ {
area := area2(points[a], points[b]) + area2(points[b], points[c]) + area2(points[c], points[a])
if area < 0 {
area = -area
}
maxArea = max(maxArea, area)
}
}
}
return maxArea
}
var _ = largestTriangleArea