求矩形中长为w,宽为h的最大子矩阵和,f[i,j]表示从(1,1)到(i,j)的和,f[i,j]=f[i,j]+f[i-1,j]+f[i,j-1]-f[i-1,j-1]

ans=max(ans,f[i,j]-f[i-w,j]-f[i,j-h]+f[i-w,j-h]

program poj2029;
var
  f:array[0..100,0..100] of integer;
  n,i,j,x,y,w,h,ww,hh,ans,s:integer;
function max(p,q:integer):integer;
begin
  if p>q then max:=p
    else max:=q;
end;
begin
  readln(n);
  while n<>0 do
  begin
    fillchar(f,sizeof(f),0);
    readln(w,h);
    for i:=1 to n do
    begin
      readln(x,y);
      inc(f[x,y]);
    end;
    readln(ww,hh);
    ans:=-maxint;
    for i:=1 to w do
      for j:=1 to h do
      begin
        f[i,j]:=f[i,j]+f[i-1,j]+f[i,j-1]-f[i-1,j-1];
        if (i>=ww) and (j>=hh) then
        begin
          s:=f[i,j]-f[i-ww,j]-f[i,j-hh]+f[i-ww,j-hh];
          ans:=max(ans,s);
        end;
      end;
    writeln(ans);
    readln(n);
  end;
end.