fork download
  1. Var i,n:longint;
  2. l,r,k:extended;
  3. x,y:array [1..15000] of extended;
  4. function f(k:extended):extended;
  5. Var rez:extended;
  6. i:longint;
  7. begin
  8. rez:=0;
  9. for i:=1 to n do
  10. rez:=rez+sqrt(y[i]*y[i]+(x[i]-k)*(x[i]-k));
  11. f:=rez;
  12. end;
  13. begin
  14. Assign(input,'input.txt'); reset(input);
  15. Assign(output,'output.txt'); rewrite(output);
  16. read(n);
  17. for i:=1 to n do
  18. read(x[i],y[i]);
  19. l:=x[1];
  20. r:=x[2];
  21. for i:=1 to 500 do
  22. begin
  23. k:=(r-l)/3;
  24. if f(l+k)>f(l+k+k)
  25. then l:=l+k
  26. else r:=l+k*2;
  27. end;
  28. writeln(r);
  29. end.
Runtime error #stdin #stdout 0s 568KB
stdin
Standard input is empty
stdout
Runtime error 2 at $08048195
  $08048195
  $08063993