Cod sursa(job #60580)

Utilizator cezar305Mr. Noname cezar305 Data 15 mai 2007 14:53:39
Problema Medie Scor 10
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.75 kb
var f1,f2:text; i,j,caut,n:longint;
    x,v,a:array[-200..9000] of longint;
    nr:int64;
begin
        assign(f1,'medie.in');
        reset(f1);
        assign(f2,'medie.out');
        rewrite(f2);
        read(f1,n);
        for i:=1 to n do
        begin
                read(f1,a[i]);
                inc(x[a[i]]);
        end;
        for i:=1 to n do
        begin
                v:=x;
                caut:=2*a[i];
                dec(v[a[i]]);
                for j:=1 to n do
                begin
                        if j<>i then dec(v[a[j]]);
                        if (j<>i)and(caut-a[j]>0) then nr:=nr+v[caut-a[j]];
                end;
        end;
        writeln(f2,nr);
        close(f1);
        close(f2);
end.