Exactly, this is what I am having a doubt.
I guess you wanted to say “si” instead of “ci”.
Adding to your point, take the case when N=4, M=20
Ouput should be 1, but the solutions mentioned in the editorial is 2, which is wrong according to problem statement.
I guess you are again confusing ci with si. Considering prime factors of 20 i.e 2 and 5 will give ci values. So, let ci = 2 and cj = 5 (number of windows in a column) then si = 10 and sj = 4 (sizes of every window in a column). Using these sizes we can see that they will never meet at a horizontal level. (SEE THE IMAGE ATTACHED).