Reminder: in case of any technical issues, you can use the lightweight website m1.codeforces.com, m2.codeforces.com, m3.codeforces.com. ×

N checkpoint problem.

Revision en3, by atlasworld, 2019-02-24 00:10:18

You are given n checkpoints in (x , y) plane . you have to choose any two pairs i , j (j can be = i ) such that (xj-xi) + (yj-yi) = k

How to solve it in O(n) time .

N = 1e5 .

xi, yi = -1e9 , 1e9

Any idea.

example :

N = 4

(-2 , 2 ) , (0 , 3) , (1 ,2 ) , (1, 2)

k = 0 .

ans = 10

pairs are (1,1) (2,2) (3,3) (4,4) , (2,3) , (2,4) , (3,2) , (3,4) , (4,2) , (4,3)

#### History

Revisions

Rev. Lang. By When Δ Comment
en3 atlasworld 2019-02-24 00:10:18 8
en2 atlasworld 2019-02-24 00:09:49 174
en1 atlasworld 2019-02-24 00:06:40 238 Initial revision (published)