Why sorting doesn't change the relative ordering? (i<j)

Codeforces Round #627 D - Pair of Topics-

https://codeforces.com/contest/1324/problem/D
My Doubt is

why sorting doesn’t change the relative ordering??
(i<j) condition ka kya Hua??
Please Explain
Can Similar Approach be applied While Finding Inversion Counts??

@gupta.tushar68

The pair of topics i and j (i<j) is called good if ai+aj>bi+bj (i.e. it is more interesting for the teacher).

The order of i,j does not matter here, its just that i should not be equal to j.
the expression ai+aj>bi+bj is independent of whether you use i<j or j<i.
Similar approach cannot be used in inversion counts, because in that the condition is a[i] > a[j], i < j.

1 Like