GPMB - Giải phóng mặt bằng
Tác giả: flashmt
Ngôn ngữ: Pascal
const fi='';
fo='';
maxn=1500;
delta=12345678901;
var n,re,dem:longint;
x,y,s,ss:array[1..maxn] of longint;
a:array[1..maxn] of real;
procedure rf;
var i:longint;
begin
read(n);
for i:=1 to n do read(x[i],y[i],s[i]);
end;
procedure sort(l,r:longint);
var i,j,u:longint; x,y:real;
begin
i:=l; j:=r; x:=a[(i+j) shr 1];
repeat
while a[i]<x do i:=i+1;
while a[j]>x do j:=j-1;
if i<=j then
begin
y:=a[i]; a[i]:=a[j]; a[j]:=y;
u:=ss[i]; ss[i]:=ss[j]; ss[j]:=u;
i:=i+1; j:=j-1;
end;
until i>j;
if i<r then sort(i,r);
if l<j then sort(l,j);
end;
procedure pr;
var i,t,u,k,j:longint;
begin
re:=0;
for i:=1 to n do
begin
dem:=0;
for j:=1 to n do
if i<>j then
begin
dem:=dem+1;
if x[i]=x[j] then a[dem]:=delta
else a[dem]:=(y[j]-y[i])/(x[j]-x[i]);
ss[dem]:=s[j]*s[j]+5;
end;
sort(1,dem);
t:=0; u:=ss[1]; k:=1;
for j:=2 to dem do
if a[j]=a[k] then u:=u+ss[j]
else
begin
if u>t then t:=u;
u:=ss[j]; k:=j;
end;
if u>t then t:=u;
if t+s[i]*s[i]+5>re then re:=t+s[i]*s[i]+5;
end;
end;
procedure wf;
begin
writeln(re);
end;
begin
assign(input,fi); reset(input);
assign(output,fo); rewrite(output);
rf;
pr;
wf;
close(input); close(output);
end.