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. we: array[0..2001, 0..2001]of extended;
  14. s, len: extended;
  15.  
  16. function f(k: integer): integer;
  17. begin
  18. s := we[i, j] + a[k] - a[i];
  19.  
  20. l := j;
  21. r := m + 1;
  22. while (r - l) > 1 do begin
  23. mid := (r + l) div 2;
  24. if len + eps >= (s + b[mid] - b[j] + we[k, mid]) then
  25. l := mid
  26. else
  27. r := mid;
  28. end;
  29.  
  30. mid := l;
  31. if len + eps >= (s + b[mid] - b[j] + we[k, mid]) then
  32. result := k - i + 1 + mid - j + 1
  33. else
  34. result := 0;
  35. end;
  36.  
  37. begin
  38. reset(input, 'birch.in');
  39. rewrite(output, 'birch.out');
  40.  
  41. read(len, w);
  42.  
  43. read(n);
  44. for i := 1 to n do
  45. read(a[i]);
  46.  
  47. read(m);
  48. for i := 1 to m do
  49. read(b[i]);
  50.  
  51. for i := 1 to n do
  52. for j := 1 to m do begin
  53. we[i, j] := sqrt( (a[i] - b[j]) * (a[i] - b[j]) + (w) * (w) );
  54. end;
  55.  
  56. ans := 0;
  57.  
  58. for i := 1 to n do
  59. for j := 1 to m do begin
  60. ll := i;
  61. rr := n + 2;
  62.  
  63. while (rr - ll) > 2 do begin
  64. m1 := ll + (rr - ll) div 3;
  65. m2 := rr - (rr - ll) div 3;
  66.  
  67. if f(m1) >= f(m2) then
  68. rr := m2
  69. else
  70. ll := m1;
  71.  
  72. end;
  73.  
  74. ans := max(ans, f(ll));
  75. ans := max(ans, f(min(ll + 1, n)));
  76.  
  77. if ans = n + m then begin
  78. write(ans);
  79. exit;
  80. end;
  81.  
  82. end;
  83.  
  84. write(ans);
  85.  
  86.  
  87. end.
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