a53

pct_of

a53
Apr 2nd, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <fstream>
  2. #define N 1002
  3. using namespace std;
  4. int a[N][N],b[N][N],c[N];
  5.  
  6. int main()
  7. {
  8. int n,k;
  9. ifstream f("pct.in");
  10. f>>n>>k;
  11. int x,y;
  12. for(int i=1;i<=n;++i)
  13. f>>x>>y,a[x+1][y+1]=1;
  14. f.close();
  15. for(int i=1;i<=1001;++i)
  16. for(int j=1;j<=1001;++j)
  17. c[j]+=a[i][j],b[i][j]=b[i][j-1]+c[j];
  18. int nr,maxim=0;
  19. for(int i=1;i<=1001-k;++i)
  20. for(int j=1;j<=1001-k;++j)
  21. {
  22. nr=b[i+k][j+k]-b[i+k][j-1]-b[i-1][j+k]+b[i-1][j-1];
  23. if(nr>maxim)
  24. maxim=nr;
  25. }
  26. ofstream g("pct.out");
  27. g<<maxim;
  28. g.close();
  29. return 0;
  30. }
Add Comment
Please, Sign In to add comment