Cod sursa(job #156839)

Utilizator valytgjiu91stancu vlad valytgjiu91 Data 12 martie 2008 19:24:55
Problema Bilute Scor 50
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.6 kb
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);
for i:=1 to n do
    for j:=1 to n do
       if j<>i then
             v[i]:=v[i]+((a[j].x*a[j].y)+(a[j].x*abs(j-i)));
max:=v[1];
j:=1;
for i:=2 to n do
   if max>v[i] then begin
                     max:=v[i];
                     j:=i;
                     end;
assign(g,'bilute.out');
rewrite(g);
write(g,j,' ',max);
close(g);
end.