We defer the constructions to the end of the solution. Instead, we begin by characterizing all such functions f, prove a formula and key property for such functions, and then solve the problem, providing constructions.
Characterization Suppose f satisfies the given relation. The condition can be written more strongly as
f(x1,y1)>f(x2,y2)⟺f(x1+1,y1)>f(x2+1,y2)⟺f(x1,y1+1)>f(x2,y2+1)
In particular, this means for any (k,l)∈Z2,f(x+k,y+l)−f(x,y) has the same sign for all x and y.
Call a non-zero vector (k,l)∈Z⩾0×Z⩾0 a needle if f(x+k,y)−f(x,y+l)>0 for all x and y. It is not hard to see that needles and non-needles are both closed under addition, and thus under scalar division (whenever the quotient lives in Z2 ).
In addition, call a positive rational number lk a grade if the vector (k,l) is a needle. (Since needles are closed under scalar multiples and quotients, this is well-defined.)
Claim. Grades are closed upwards.
Proof. Consider positive rationals k1/l1<k2/l2 with k1/l1 a grade. Then:
- (k1,l1) is a needle
- so (k1l2,l1l2) is a needle,
- so (k2l1,l1l2) is a needle (as k2l1−k1l2>0 and (1,0) is a needle).
Thus ( k2,l2 ) is a needle, as wanted.
Claim. A grade exists.
Proof. If no positive integer n is a grade, then f(1,0)>f(0,n) for all n which is impossible.
Similarly, there is an n such that f(0,1)<f(n,0), thus 1/n is not a grade for some large n. That means that small positive rational values are not grades, then there is a switch, and after that all values are grades. Call the place of that switch α. Here α is the infimum of the grades.
Claim (Key property). If x1+y1α>x2+y2α then f(x1,y1)>f(x2,y2).
Proof. If both x1⩾x2 and y1⩾y2 this is clear.
Suppose x1⩾x2 and y1<y2. Then y2−y1x1−x2>α is a grade. This gives f(x1,y1)>f(x2,y2). Suppose x1<x2 and y1⩾y2. Then u1−u2x2−x1<α is not a grade. This gives f(x2,y2)<f(x1,y1).
From those observations we get the following claim.
Claim. The function f orders pairs (x,y) based on the value of x+yα. If α is rational, tiebreaking is done by larger x - or y-coordinate (depending on whether α is a grade).
We can imagine this the following way: take a line with slope −α1 under the first quadrant of the plane. And we start to move this line upward (but it stays parallel to the original line). First it hits (0,0), so f(0,0)=0. And each time the line hits a point p,f(p) is the number of points hit before. If α∈Q, it is possible that the line hits multiple points. Then those points are ordered the same way as their x or y coordinates, depending on whether α is a grade.
We understood the behaviour of f, now we need to focus on the region of A={(x,y)∈Z⩾0×Z⩾0∣x<100,y<100}. First, we can assume that α is irrational. If we change it a little bit in the right direction, the behaviour and values of the f function does not change in A.
Claim.
f(x,y)+f(x+1,y+1)=f(x+1,y)+f(x,y+1)+1
Proof.
f(x+1,y+1)−f(x,y+1)=#{(a,b)∈Z⩾0×Z⩾0∣x+(y+1)α⩽a+bα<(x+1)+(y+1)α}=#{(a,b)∈Z⩾0×Z>0∣x+(y+1)α⩽a+bα<(x+1)+(y+1)α}+#{(a,0)∈Z⩾0×Z⩾0∣(x+1)+yα⩽a<(x+1)+(y+1)α}=#{(a,b)∈Z⩾0×Z⩾0∣x+yα⩽a+bα<(x+1)+yα}+1=f(x+1,y)−f(x,y).
From this claim we immediately get that 2500⩽N⩽7500; now we show that those bounds are indeed sharp.
Remember that if α is irrational then
f(a,b)=#{(x,y)∈Z⩾0×Z⩾0∣x+yα<a+bα}
Construction for 7500 Select α≈199.999.
Claim.
1. f(n,0)=n for 0⩽n⩽100.
2. f(0,k)≡kmod2 for 0⩽k⩽100.
Proof.
1. f(n,0)=#{(x,y)∣x+yα<n}=#{(x,y)∣x+199y<n}=n.
2.
f(0,k)=#{(x,y)∣x+yα<kα}=l=0∑k−1#{(x,l)∣x+lα<kα}=l=0∑k−1#{x∣x<(k−l)α}=l=0∑k−1200(k−l)−1=200A−k
for some integer A.
From this claim, using the equality f(x,y)+f(x+1,y+1)=f(x+1,y)+f(x,y+1)+1, we can prove that mod2 the region A looks like the following: in the rows (−,2y) the remainders modulo 2 alternate, while the rows (−,2y+1) contain only odd numbers.
Construction for 2500 Select α≈200.001.
Claim.
1. f(n,0)=n for 0⩽n⩽100.
2. f(0,k)≡0mod2 for 0⩽k⩽100.
Proof.
1. As above.
2. Similarly to the above:
f(0,k)=#{(x,y)∣x+yα<kα}=l=0∑k−1#{(x,l)∣x+lα<kα}=l=0∑k−1#{x∣x<(k−l)α}=l=0∑k−1200(k−l)=200A
for some integer A.
Similarly to the above, we can prove that mod 2 the region A looks like the following: in the rows (−,2y) the remainder modulo 2 alternate, while the rows (−,2y+1) contain only even numbers.
Thus, the optimal bounds are 2500⩽N⩽7500.