I have a big NxN bit array with K ones (everything else is zero). Coordinates of all non-zero points are known - in other words this NxN array can be represented as an array of K pairs each containing x and y coords of a non-zero point.
Given a submatrix of HxW size, I need place it on my original NxN array such that it covers the most non-zero points.
Input: Height H and width W of submatrix
Output: x and y coords of HxW subarray which has the most ones within itself
Similar question was answered before: Maximum subarray of size HxW within a 2D matrix but in my problem is a bit more complicated since N is huge, in my case: N=60000, K<15000, H,W<10000.
Creating 60000x60000 array would be a memory kill, even if it's an array of bits. That's why I came up with idea of representing that array with all non zero points: one dimensional array of K pairs.
Everything I can come up with is super both memory and time unefficient, I'm looking for any solution that won't eat all my ram. Here's how it's meant to look like: the output would be point (4,3) since HxW subarray, which starts at this point, contains the most ones.