fork download
  1. {$APPTYPE CONSOLE}
  2. {$R-,Q-,O+}
  3.  
  4. uses
  5. SysUtils, Math;
  6.  
  7. const
  8. eps = 1e-9;
  9.  
  10. var
  11. w, n, m, i, j, l, r, mid, ans, k, ans2, x, q, ll, rr, m1, m2: integer;
  12. a, b: array[0..200001]of extended;
  13. s, len: extended;
  14.  
  15. function dist(x1, y1, x2, y2: extended): extended;
  16. begin
  17. result := sqrt( (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) );
  18. end;
  19.  
  20. function f(k: integer): integer;
  21. begin
  22. s := dist(a[i], w, b[j], 0) + a[k] - a[i];
  23.  
  24. l := j;
  25. r := m + 1;
  26. while (r - l) > 1 do begin
  27. mid := (r + l) div 2;
  28. if len + eps >= (s + b[mid] - b[j] + dist(a[k], w, b[mid], 0)) then
  29. l := mid
  30. else
  31. r := mid;
  32. end;
  33.  
  34. mid := l;
  35. if len + eps >= (s + b[mid] - b[j] + dist(a[k], w, b[mid], 0)) then
  36. result := k - i + 1 + mid - j + 1
  37. else
  38. result := 0;
  39. end;
  40.  
  41. begin
  42. {reset(input, 'birch.in');
  43.   rewrite(output, 'birch.out');}
  44.  
  45. read(len, w);
  46.  
  47. read(n);
  48. for i := 1 to n do
  49. read(a[i]);
  50.  
  51. read(m);
  52. for i := 1 to m do
  53. read(b[i]);
  54.  
  55. ans := 0;
  56.  
  57. for i := 1 to n do
  58. for j := 1 to m do begin
  59. ll := i;
  60. rr := n + 2;
  61.  
  62. while (rr - ll) > 2 do begin
  63. m1 := ll + (rr - ll) div 3;
  64. m2 := rr - (rr - ll) div 3;
  65.  
  66. if f(m1) >= f(m2) then
  67. rr := m2
  68. else
  69. ll := m1;
  70.  
  71. end;
  72.  
  73. ans := max(ans, f(ll));
  74. ans := max(ans, f(min(ll + 1, n)));
  75.  
  76. if ans = n + m then begin
  77. write(ans);
  78. exit;
  79. end;
  80.  
  81. end;
  82.  
  83. write(ans);
  84.  
  85.  
  86. end.
  87.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.pas:1: warning: unknown compiler directive `apptype console'
prog.pas:2: warning: directive `{$q-}' not yet implemented
prog.pas:2: warning: ignoring BP directive `{$o+}' which is unnecessary in GPC
prog.pas:1: warning: missing program header
prog.pas:5: error: module/unit interface `SysUtils' could not be imported
stdout
Standard output is empty