if you are doing it in O(n) then you cannot be getting tle.
and if you are getting wa then your logic is wrong.
P.S: please edit your comment as it is giving away a major hint to everyone.
my code does not check for the elements present explicitly ,like it does (IYKWIM) but yeah so the problem is that my code fails the 11th case alone and i am not able to figure it out for the past 2 days and rest of the cases are AC.
And yes it is WA for the 11th test case alone .
Pls help!!
see the thing that they are pairwise distint is that they are "unique".
and u are asked to print n+m-1 pairs .
These two are the major hints that is required to solve the problem explaning further more u dont need to put the sum and check for them theres another way where u dont need to compute the sum at all.
I guess i have revealed the max .
Try again i was struggling with this but it is a cakewalk trust me.
cheers:).