fork(1) download
  1. //nongdanjohn - THPTNguyenQuangDieu - nhatkynghiencuu.blogspot.com
  2. const maxN = 50001;
  3. var n,m,l,ans: longint;
  4. d: integer;
  5. s: array[1..maxN] of longint;
  6.  
  7. procedure enter;
  8. var i: longint;
  9. begin
  10. assign(input,''); reset(input);
  11. readln(n,m,d,l);
  12. for i:=1 to n do readln(s[i]);
  13. end;
  14.  
  15. procedure sort(l,h: longint);
  16. var i,j,t,k: longint;
  17. begin
  18. i:=l; j:=h; k:=s[(i+j) div 2];
  19. repeat
  20. while S[i]<k do inc(i);
  21. while s[j]>k do dec(j);
  22. if i<=j then
  23. begin
  24. t:=s[i]; s[i]:=s[j]; s[j]:=t;
  25. dec(j); inc(i);
  26. end;
  27. until i>j;
  28. if l<j then sort(l,j);
  29. if i<h then sort(i,h);
  30. end;
  31.  
  32. procedure solve;
  33. var i,count,j: longint;
  34. begin
  35. ans:=0; count:=0; j:=0;
  36. for i:=1 to n do
  37. if S[i]-D*j >= L then
  38. begin
  39. inc(ans);
  40. inc(count);
  41. if count=m then
  42. begin
  43. count:=0;
  44. inc(j);
  45. end;
  46. end;
  47. end;
  48.  
  49. begin
  50. enter;
  51. sort(1,n);
  52. solve;
  53. writeln(ans)
  54. end.
Success #stdin #stdout 0s 472KB
stdin
Standard input is empty
stdout
0