dragonman164's blog

By dragonman164, history, 3 years ago, In English

I am getting MLE in test case 45 for C Question. I am not able to figure out the reason for it. Time Complexity and Space Complexity of my code are O(n^2) for each. Here's my submission. Can someone figure out my issue with my code ?

https://codeforces.me/contest/1678/submission/156387534

  • Vote: I like it
  • +3
  • Vote: I do not like it

»
3 years ago, # |
  Vote: I like it +2 Vote: I do not like it

Don't save the inversions in a vector, that just uses extra time and memory. Try instead to apply the increments to the dp array directly, and in the end just loop over the array again and find the inversions instead of using the vector (a)