DPAIRS - EDITORIAL

@officialnizam Try

3 4
1 2 3
2 3 4 6

You pick both (1, 6) and (3, 4) which have the same sum.

Unbelievably, you almost got an AC, showing test cases are so weak.

3 Likes

IT CAN BE SOLVED WITHOUT SORTING. JUST FIND THE MINIMUM ELEMENT OF ONE SEQUENCE AND THE MAXIMUM ELEMENT OF THE OTHER SEQUENCE.

All the test cases, except 3 in the first subtask, have n = m.

https://www.codechef.com/viewsolution/22515213

can this problem be solved using SET?
adding elements and then inserting in the set, if size increases then display indexes.

What does it mean “Ax+By for all pairs is pairwise distinct”? Anyone.

For the editorial solution to work, either sequence A or sequence B should be unique. But no where in the problem it was mentioned or is it mentioned in the problem?

4 Likes

exactly !!
just find index of minimum and maximum values…

Can you elaborate?

vector< pair< int,int > > B(n); - should be m.

I didn’t understand what you were trying to say, but no sorting is necessary for either subtask. :slight_smile:

Everybody has figured that out - no need to SCREAM. xD

i have a question that whats the logic behind using if n != 10 condition can u explain…plzz

No logic. The condition allows the test cases to be passed. That illustrates how weak they are.

could u tell how to know that for this reason i am getting the wrong aswer…plzz?

I did the same thing but I get WA on 3 testcases , AC on 4 and TLE on subtask 2

@manasi2399 You don’t need to use container except vector that too for storing the sequence. Read the problem statement carefully. Although people have already gave an idea about how you can solve the problem easily with just a small observation.

Yes I read the editorial and realise I dont need another container. However I expected that the logic I applied (even though inefficient) shouldn’t give WA on atleast subtask 1. It would be great if I could see the testcases on which it fails :frowning:

Well if it is giving WA then you are certainly missing something. Share your code with brief explanation about what your have done.

@striker22
I figured out my mistake . I was doing i+j instead of a[i] + b[j] . I can be really stupid sometimes. Thanks for your help !

What @semantycs is correct. You’re printing new indices.