Pagini recente » Cod sursa (job #2904963) | Cod sursa (job #2878421) | Cod sursa (job #1700202) | Cod sursa (job #725226) | Cod sursa (job #156859)
Cod sursa(job #156859)
var f,g:text;
a:array[1..30000] of record
x,y:byte;
end;
v:array[1..30000] of longint;
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:=2000000000;
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 max:=v[i];
end;
j:=1;
for i:=2 to n do
if max=v[i] then begin
j:=i;
break;
end;
assign(g,'bilute.out');
rewrite(g);
write(g,j,' ',max);
close(g);
end.