Comments

constraints:
1 <= N <= 150000
1 <= A[i] <= 1e9

Is your approach, fenwick tree to calculate the number of elements greater than or equal to A[i] (lets call this count as c) and multiply it with A[i]?

lets assume we updated the fenwick tree and calculated the answer for prefix ending at i. for the prefix i+1, if we add the A[i+1] in the tree, it will change the "c" of elements less than or equal to A[i+1] and that will change the value c*A[j] (j from 0 to i, where A[j] <= A[i+1]). In that case, we should calculate again for prefix ending at i.
wouldn't it lead to n^2 solution?

Is your approach, calculate value at an index i and compare the value with the previous ans?

But the element at this index can affect ans calculated before.

On MangoosteGlobal Round 19 Editorial, 5 years ago
+2

Nice explanation by vishwas_007

On YouKn0wWhoCodeforces Round #752, 5 years ago
+46

Does anyone know why Itst_boyfriend was removed from the contest?

when you go to sleep and when you wake up?

I also gave the same input

I found that after giving invalid input for hacking

cc is the internet explorer of the programming websites.

On scott_wuI'm scott_wu. AMA!, 6 years ago
+5

how you got the idea for lunchclub?

a weird way to climb up the leaderboard...