Pagini recente » Cod sursa (job #530543) | Cod sursa (job #330867) | Cod sursa (job #2432076) | Cod sursa (job #2245792) | Cod sursa (job #156879)
Cod sursa(job #156879)
var f,g:text;
a:array[1..3000] of record
x,y:byte;
end;
v:array[1..3000] of longint;
k,n,i,j:integer;
max:longint;
begin
assign(f,'bilute.in');
reset(f);
readln(f,n);
for i:=1 to n do
readln(f,a[i].x,a[i].y);
close(f);
max:=2147483647;
for i:=1 to n do
begin
for j:=1 to n do
begin
if (j<>i) then
v[i]:=v[i]+((a[j].x*a[j].y)+(a[j].x*abs(j-i)));
if v[i]>max then break;
end;
if v[i]<max then
begin
max:=v[i];
k:=i;
end;
end;
assign(g,'bilute.out');
rewrite(g);
write(g,k,' ',max);
close(g);
end.