prob: https://atcoder.jp/contests/abc194/tasks/abc194_c
Not able to understand the editorial please explain
prob: https://atcoder.jp/contests/abc194/tasks/abc194_c
Not able to understand the editorial please explain
hello @raghav007
note following things
a) if we brute force the given formula then time complexity will be O(n^2) (a tle solutiom)
b) what forumla is doing ? it is just calculating square of all possible pairs right?
so if any number a occurs A times and a number b occurs B times in an array then what will be there overall contribution in the answer.
it will be (b-a) * (b-a) * A * B right?
so u have to do the same thing.
first prepare a frequency array and then use above formula among every possible pair to get ur answer.
c) Ai < = 200 that measn possible pairs will be less than 200 * 200
so this solutio will work
ohh okay to come with this formula is there a specific thing I need to study or this too comes with practice
with practice, and bit of pnc knowledge
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.